commit 40f762b2c477bbea7b31bac40b88815424389b6f from: Omar Polo date: Fri Sep 23 14:38:53 2022 UTC fix reconfiguration commit - db3f5b3d9376ab01d715c97ca6d81d124148e214 commit + 40f762b2c477bbea7b31bac40b88815424389b6f blob - 85ab8b5f4bd8b509d4bde8cd3530d3a0e737fff5 blob + 29a059971b71c3a00cd6a834fea8551a6f2bcbd7 --- config.c +++ config.c @@ -61,7 +61,29 @@ void config_purge(struct galileo *env) { struct proxy *p; + struct fcgi *fcgi; + struct client *clt; + while ((fcgi = SPLAY_MIN(fcgi_tree, &env->sc_fcgi_socks))) { + while ((clt = SPLAY_MIN(client_tree, &fcgi->fcg_clients))) { + if (fcgi_abort_request(clt) == -1) { + fcgi = NULL; + break; + } + } + + if (fcgi == NULL) + break; + + SPLAY_REMOVE(fcgi_tree, &env->sc_fcgi_socks, fcgi); + fcgi_free(fcgi); + } + + event_del(&env->sc_evsock); + event_del(&env->sc_evpause); + close(env->sc_sock_fd); + env->sc_sock_fd = -1; + while ((p = TAILQ_FIRST(&env->sc_proxies)) != NULL) { TAILQ_REMOVE(&env->sc_proxies, p, pr_entry); proxy_purge(p); @@ -209,7 +231,8 @@ config_setreset(struct galileo *env) int id; for (id = 0; id < PROC_MAX; ++id) - proc_compose(ps, id, IMSG_CTL_RESET, NULL, 0); + if (id != PROC_PARENT) + proc_compose(ps, id, IMSG_CTL_RESET, NULL, 0); return (0); } @@ -221,3 +244,13 @@ config_getreset(struct galileo *env, struct imsg *imsg return (0); } + +int +config_getcfg(struct galileo *env, struct imsg *imsg) +{ + if (privsep_process != PROC_PARENT) + proc_compose(env->sc_ps, PROC_PARENT, + IMSG_CFG_DONE, NULL, 0); + + return (0); +} blob - eefdebd9133659a6c4508cee70e7fd4a327b5d8d blob + 9f7c33896bdb131bad0479e007b5b5ab8fcb46e1 --- fcgi.c +++ fcgi.c @@ -671,12 +671,18 @@ fcgi_error(struct bufferevent *bev, short event, void proxy_client_free(clt); } - close(fcgi->fcg_s); - bufferevent_free(fcgi->fcg_bev); SPLAY_REMOVE(fcgi_tree, &env->sc_fcgi_socks, fcgi); - free(fcgi); + fcgi_free(fcgi); return; +} + +void +fcgi_free(struct fcgi *fcgi) +{ + close(fcgi->fcg_s); + bufferevent_free(fcgi->fcg_bev); + free(fcgi); } int blob - a38a60da468bf5ad2865b1c79aad657f6004560a blob + bf98d629cc4c0d09bc31b340d5c7eef05b2dbb67 --- galileo.h +++ galileo.h @@ -154,6 +154,7 @@ int config_setsock(struct galileo *); int config_getsock(struct galileo *, struct imsg *); int config_setreset(struct galileo *); int config_getreset(struct galileo *, struct imsg *); +int config_getcfg(struct galileo *, struct imsg *); /* fcgi.c */ int fcgi_end_request(struct client *, int); @@ -162,6 +163,7 @@ void fcgi_accept(int, short, void *); void fcgi_read(struct bufferevent *, void *); void fcgi_write(struct bufferevent *, void *); void fcgi_error(struct bufferevent *, short error, void *); +void fcgi_free(struct fcgi *); int clt_putc(struct client *, char); int clt_puts(struct client *, const char *); int clt_write_bufferevent(struct client *, struct bufferevent *); blob - 0df1ed9f548dcc1db5f6032cd82aa4a9bae76433 blob + 24ddb43bf40a4b79eca2a12a62f3d17b56285be0 --- proxy.c +++ proxy.c @@ -101,8 +101,9 @@ proxy_launch(struct galileo *env) } void -proxy_purge(struct proxy *srv) +proxy_purge(struct proxy *pr) { + free(pr); } void @@ -127,28 +128,24 @@ proxy_dispatch_parent(int fd, struct privsep_proc *p, case IMSG_CFG_SOCK: /* XXX: improve */ - if (env->sc_sock_fd != -1) { - event_del(&env->sc_evsock); - close(env->sc_sock_fd); - } - env->sc_sock_fd = config_getsock(env, imsg); if (env->sc_sock_fd == -1) fatal("config_getsock"); event_set(&env->sc_evsock, env->sc_sock_fd, EV_READ | EV_PERSIST, fcgi_accept, env); - event_add(&env->sc_evsock, NULL); evtimer_set(&env->sc_evpause, fcgi_accept, env); break; case IMSG_CFG_DONE: - log_debug("config done!"); + config_getcfg(env, imsg); + proxy_launch(env); break; case IMSG_CTL_START: - proxy_launch(env); break; + case IMSG_CTL_RESET: + config_getreset(env, imsg); + break; default: - log_warnx("unknown message %d", imsg->hdr.type); return (-1); }