X-Git-Url: https://jfr.im/git/solanum.git/blobdiff_plain/ab9088ad2edc394ea9d78050604cc10d7a36ee9f..e02cc991bb9a7b9aac65b70d167002cea12bad46:/ircd/wsproc.c diff --git a/ircd/wsproc.c b/ircd/wsproc.c index 2a0d34ac..973826b1 100644 --- a/ircd/wsproc.c +++ b/ircd/wsproc.c @@ -37,9 +37,6 @@ static void ws_read_ctl(rb_fde_t * F, void *data); static int wsockd_count; -static char tmpbuf[READBUF_SIZE]; -static char nul = '\0'; - #define MAXPASSFD 4 #define READSIZE 1024 typedef struct _ws_ctl_buf @@ -197,7 +194,7 @@ ws_dead(ws_ctl_t * ctl) { wsockd_count--; ilog(L_MAIN, "wsockd helper died - attempting to restart"); - sendto_realops_snomask(SNO_GENERAL, L_ALL, "wsockd helper died - attempting to restart"); + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "wsockd helper died - attempting to restart"); start_wsockd(1); } } @@ -226,7 +223,7 @@ restart_wsockd_event(void *unused) { int start = ServerInfo.wsockd_count - get_wsockd_count(); ilog(L_MAIN, "Attempting to restart wsockd processes"); - sendto_realops_snomask(SNO_GENERAL, L_ALL, "Attempting to restart wsockd processes"); + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "Attempting to restart wsockd processes"); start_wsockd(start); } } @@ -236,12 +233,6 @@ start_wsockd(int count) { rb_fde_t *F1, *F2; rb_fde_t *P1, *P2; -#ifdef _WIN32 - const char *suffix = ".exe"; -#else - const char *suffix = ""; -#endif - char fullpath[PATH_MAX + 1]; char fdarg[6]; const char *parv[2]; @@ -256,7 +247,7 @@ start_wsockd(int count) if(wsockd_spin_count > 20 && (rb_current_time() - last_spin < 5)) { ilog(L_MAIN, "wsockd helper is spinning - will attempt to restart in 1 minute"); - sendto_realops_snomask(SNO_GENERAL, L_ALL, + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "wsockd helper is spinning - will attempt to restart in 1 minute"); rb_event_add("restart_wsockd_event", restart_wsockd_event, NULL, 60); wsockd_wait = 1; @@ -268,17 +259,16 @@ start_wsockd(int count) if(wsockd_path == NULL) { - snprintf(fullpath, sizeof(fullpath), "%s%cwsockd%s", ircd_paths[IRCD_PATH_LIBEXEC], RB_PATH_SEPARATOR, suffix); + snprintf(fullpath, sizeof(fullpath), "%s/wsockd", ircd_paths[IRCD_PATH_LIBEXEC]); if(access(fullpath, X_OK) == -1) { - snprintf(fullpath, sizeof(fullpath), "%s%cbin%cwsockd%s", - ConfigFileEntry.dpath, RB_PATH_SEPARATOR, RB_PATH_SEPARATOR, suffix); + snprintf(fullpath, sizeof(fullpath), "%s/bin/wsockd", ConfigFileEntry.dpath); if(access(fullpath, X_OK) == -1) { ilog(L_MAIN, - "Unable to execute wsockd%s in %s or %s/bin", - suffix, ircd_paths[IRCD_PATH_LIBEXEC], ConfigFileEntry.dpath); + "Unable to execute wsockd in %s or %s/bin", + ircd_paths[IRCD_PATH_LIBEXEC], ConfigFileEntry.dpath); return 0; } } @@ -311,10 +301,8 @@ start_wsockd(int count) snprintf(s_pid, sizeof(s_pid), "%d", (int)getpid()); rb_setenv("CTL_PPID", s_pid, 1); -#ifdef _WIN32 - SetHandleInformation((HANDLE) rb_get_fd(F2), HANDLE_FLAG_INHERIT, 1); - SetHandleInformation((HANDLE) rb_get_fd(P1), HANDLE_FLAG_INHERIT, 1); -#endif + rb_clear_cloexec(F2); + rb_clear_cloexec(P1); pid = rb_spawn_process(wsockd_path, (const char **) parv); if(pid == -1) @@ -334,6 +322,8 @@ start_wsockd(int count) ws_do_pipe(P2, ctl); } + ilog(L_MAIN, "wsockd helper started"); + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "wsockd helper started"); return started; } @@ -369,7 +359,6 @@ ws_process_cmd_recv(ws_ctl_t * ctl) { rb_dlink_node *ptr, *next; ws_ctl_buf_t *ctl_buf; - unsigned long len; if(ctl->dead) return; @@ -384,7 +373,7 @@ ws_process_cmd_recv(ws_ctl_t * ctl) break; default: ilog(L_MAIN, "Received invalid command from wsockd: %s", ctl_buf->buf); - sendto_realops_snomask(SNO_GENERAL, L_ALL, "Received invalid command from wsockd"); + sendto_realops_snomask(SNO_GENERAL, L_NETWIDE, "Received invalid command from wsockd"); break; } rb_dlinkDelete(ptr, &ctl->readq);