/* -*-c-*-
*
- * $Id: socket.c,v 1.7 2001/06/22 19:37:00 mdw Exp $
+ * $Id: socket.c,v 1.9 2002/02/23 00:08:00 mdw Exp $
*
* Socket source and target definitions
*
/*----- Revision history --------------------------------------------------*
*
* $Log: socket.c,v $
+ * Revision 1.9 2002/02/23 00:08:00 mdw
+ * Fix stupid bugs from the listen(2) change.
+ *
+ * Revision 1.8 2002/02/22 23:44:44 mdw
+ * Call @xfree@ rather than @free@. Add option to change the listen(2)
+ * parameter.
+ *
* Revision 1.7 2001/06/22 19:37:00 mdw
* New @conn_init@ interface.
*
typedef struct ssource_opts {
unsigned opt;
unsigned conn;
+ unsigned listen;
} ssource_opts;
-static ssource_opts ssgo = { 256, 0 };
+static ssource_opts ssgo = { 256, 0, 5 };
#define SOCKOPT_LIMIT 0u
#define SOCKOPT_NOLIMIT 1u
REFFD_DEC(ee->e.out);
}
- free(ee->desc);
+ xfree(ee->desc);
fw_dec();
DESTROY(ee);
}
CONF_ACCEPT;
}
+ if (strcmp(sc->d.buf, "listen") == 0) {
+ token(sc);
+ if (sc->t == '=')
+ token(sc);
+ if (sc->t != CTOK_WORD || !isdigit((unsigned char)sc->d.buf[0]))
+ error(sc, "parse error, expected number");
+ sso->listen = atoi(sc->d.buf);
+ if (sso->listen == 0)
+ error(sc, "argument of `listen' must be positive");
+ token(sc);
+ CONF_ACCEPT;
+ }
+
if (strcmp(sc->d.buf, "logging") == 0 ||
strcmp(sc->d.buf, "log") == 0) {
addr_opts *ao = ss ? ss->ao : &gao;
/* --- Set it to listen for connections --- */
- if (listen(fd, 5)) {
+ if (listen(fd, ss->o.listen)) {
fw_log(-1, "[%s] couldn't listen on socket: %s",
ss->s.desc, strerror(errno));
goto fail_1;
/* --- Set it to listen for connections --- */
- if (listen(fd, 5))
+ if (listen(fd, ss->o.listen))
error(sc, "couldn't listen on socket: %s", strerror(errno));
}
ss->a->ops->freeopts(ss->ao);
else
DESTROY(ss->ao);
- free(ss->s.desc);
+ xfree(ss->s.desc);
ss->a->ops->destroy(ss->a);
ss->t->ops->destroy(ss->t);
source_remove(&ss->s);
{
starget *st = (starget *)t;
st->a->ops->destroy(st->a);
- free(st->t.desc);
+ xfree(st->t.desc);
DESTROY(st);
}