* Copyright (c) 1987-2011 by the citadel.org team
*
* This program is open source software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
+ * it under the terms of the GNU General Public License, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "sysdep.h"
#include <sys/select.h>
#endif
-#ifndef HAVE_SNPRINTF
-#include "snprintf.h"
-#endif
-
#include "ctdl_module.h"
#include "threads.h"
#include "user_ops.h"
void close_masters (void)
{
struct ServiceFunctionHook *serviceptr;
-
+ const char *Text;
+
/*
* close all protocol master sockets
*/
if (serviceptr->tcp_port > 0)
{
- syslog(LOG_INFO, "Closing %d listener on port %d\n",
+ if (serviceptr->msock == -1)
+ Text = "not closing again";
+ else
+ Text = "Closing";
+
+ syslog(LOG_INFO, "%s %d listener on port %d\n",
+ Text,
serviceptr->msock,
serviceptr->tcp_port);
serviceptr->tcp_port = 0;
}
if (serviceptr->sockpath != NULL)
- syslog(LOG_INFO, "Closing %d listener on '%s'\n",
+ {
+ if (serviceptr->msock == -1)
+ Text = "not closing again";
+ else
+ Text = "Closing";
+
+ syslog(LOG_INFO, "%s %d listener on '%s'\n",
+ Text,
serviceptr->msock,
serviceptr->sockpath);
+ }
+
if (serviceptr->msock != -1)
+ {
close(serviceptr->msock);
+ serviceptr->msock = -1;
+ }
+
/* If it's a Unix domain socket, remove the file. */
if (serviceptr->sockpath != NULL) {
unlink(serviceptr->sockpath);
CtdlDestroyCleanupHooks();
CtdlDestroyFixedOutputHooks();
CtdlDestroySessionHooks();
+ CtdlDestroyTDAPVetoHooks();
CtdlDestroyServiceHook();
CtdlDestroyRoomHooks();
CtdlDestroySearchHooks();
+ CtdlDestroyDebugTable();
#ifdef HAVE_BACKTRACE
/// eCrash_Uninit();
#endif
}
waitpid(current_child, &status, 0);
}
- do_restart = 0;
+
nFireUpsNonRestart = nFireUps;
/* Exit code 0 means the watcher should exit */
CitContext *con = NULL; /* Temporary context pointer */
int i;
+ pthread_mutex_lock(&ThreadCountMutex);
++num_workers;
+ pthread_mutex_unlock(&ThreadCountMutex);
while (!server_shutting_down) {
SKIP_SELECT:
/* We're bound to a session */
+ pthread_mutex_lock(&ThreadCountMutex);
++active_workers;
+ pthread_mutex_unlock(&ThreadCountMutex);
+
if (bind_me != NULL) {
become_session(bind_me);
dead_session_purge(force_purge);
do_housekeeping();
+
+ pthread_mutex_lock(&ThreadCountMutex);
--active_workers;
+ if ((active_workers + config.c_min_workers < num_workers) &&
+ (num_workers > config.c_min_workers))
+ {
+ num_workers--;
+ pthread_mutex_unlock(&ThreadCountMutex);
+ return (NULL);
+ }
+ pthread_mutex_unlock(&ThreadCountMutex);
}
/* If control reaches this point, the server is shutting down */
+ pthread_mutex_lock(&ThreadCountMutex);
--num_workers;
+ pthread_mutex_unlock(&ThreadCountMutex);
return(NULL);
}