X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fngircd%2Fconn.c;h=f62e96754fa9ef610ef556f246f7b6f3711648cd;hb=HEAD;hp=61f296ab5d1e6c4359a302f744f9cbae88ce8568;hpb=e4873b4d63d0bcd4914a1cee82599a13cfd77e47;p=ngircd-alex.git diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c index 61f296ab..68a901d0 100644 --- a/src/ngircd/conn.c +++ b/src/ngircd/conn.c @@ -669,8 +669,9 @@ Conn_Handler(void) int i; size_t wdatalen; struct timeval tv; - time_t t; + time_t t, notify_t = 0; bool command_available; + char status[200]; Log(LOG_NOTICE, "Server \"%s\" (on \"%s\") ready.", Client_ID(Client_ThisServer()), Client_Hostname(Client_ThisServer())); @@ -783,13 +784,24 @@ Conn_Handler(void) exit(1); } - /* Should ngIRCd timeout when idle? */ + t = time(NULL); if (Conf_IdleTimeout > 0 && NumConnectionsAccepted > 0 - && idle_t > 0 && time(NULL) - idle_t >= Conf_IdleTimeout) { + && idle_t > 0 && t - idle_t >= Conf_IdleTimeout) { + /* Should ngIRCd timeout when idle? */ LogDebug("Server idle timeout reached: %d second%s. Initiating shutdown ...", Conf_IdleTimeout, Conf_IdleTimeout == 1 ? "" : "s"); NGIRCd_SignalQuit = true; + } else if (Signal_NotifySvcMgr_Possible() && t - notify_t > 3) { + /* Send the current status to the service manager. */ + snprintf(status, sizeof(status), + "WATCHDOG=1\nSTATUS=%ld connection%s established (%ld user%s, %ld server%s), %ld maximum. %ld accepted in total.\n", + (long)NumConnections, NumConnections == 1 ? "" : "s", + Client_MyUserCount(), Client_MyUserCount() == 1 ? "" : "s", + Client_MyServerCount(), Client_MyServerCount() == 1 ? "" : "s", + (long)NumConnectionsMax, (long)NumConnectionsAccepted); + Signal_NotifySvcMgr(status); + notify_t = t; } }