diff options
Diffstat (limited to 'cfg.c')
-rw-r--r-- | cfg.c | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -181,15 +181,17 @@ void mog_cfg_validate_or_die(struct mog_cfg *cli) mog_set_maxconns(cli->maxconns); } -static int bind_or_die(struct mog_addrinfo *a, const char *accept_filter) +static struct mog_fd * +bind_or_die(struct mog_addrinfo *a, struct mog_svc *svc, mog_post_accept_fn fn) { int fd; - if (a == NULL) return -1; - fd = mog_bind_listen(a->addr, accept_filter); - if (fd >= 0) return fd; + if (a == NULL) return NULL; + fd = mog_bind_listen(a->addr); + if (fd < 0) + die_errno("addr=%s failed to bind+listen", a->orig); - die_errno("addr=%s failed to bind+listen", a->orig); + return mog_accept_init(fd, svc, a, fn); } static bool svc_from_cfg(void *cfg_ptr, void *ignored) @@ -202,13 +204,14 @@ static bool svc_from_cfg(void *cfg_ptr, void *ignored) if (!svc) die("failed to load svc from docroot=%s", cfg->docroot); - svc->mgmt_fd = bind_or_die(cfg->mgmtlisten, "dataready"); + svc->mgmt_mfd = bind_or_die(cfg->mgmtlisten, svc, mog_mgmt_post_accept); if (cfg->server && strcmp(cfg->server, "none") == 0) return true; - svc->http_fd = bind_or_die(cfg->httplisten, "httpready"); - svc->httpget_fd = bind_or_die(cfg->httpgetlisten, "httpready"); + svc->http_mfd = bind_or_die(cfg->httplisten, svc, mog_http_post_accept); + svc->httpget_mfd = bind_or_die(cfg->httpgetlisten, svc, + mog_httpget_post_accept); return true; } |