projects
/
citadel.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
THREADS: re-install the max workers & min spare workers configs; lock thread count...
[citadel.git]
/
citadel
/
sysdep.c
diff --git
a/citadel/sysdep.c
b/citadel/sysdep.c
index 1caf2ce10b403987d9d8e53df1a3f89cafe44dd7..4ea07f3edcd95ffc34802439689098d83d7245c8 100644
(file)
--- a/
citadel/sysdep.c
+++ b/
citadel/sysdep.c
@@
-1157,7
+1157,9
@@
void *worker_thread(void *blah) {
CitContext *con = NULL; /* Temporary context pointer */
int i;
CitContext *con = NULL; /* Temporary context pointer */
int i;
+ pthread_mutex_lock(&ThreadCountMutex);
++num_workers;
++num_workers;
+ pthread_mutex_unlock(&ThreadCountMutex);
while (!server_shutting_down) {
while (!server_shutting_down) {
@@
-1339,7
+1341,10
@@
do_select: force_purge = 0;
SKIP_SELECT:
/* We're bound to a session */
SKIP_SELECT:
/* We're bound to a session */
+ pthread_mutex_lock(&ThreadCountMutex);
++active_workers;
++active_workers;
+ pthread_mutex_unlock(&ThreadCountMutex);
+
if (bind_me != NULL) {
become_session(bind_me);
if (bind_me != NULL) {
become_session(bind_me);
@@
-1373,11
+1378,22
@@
SKIP_SELECT:
dead_session_purge(force_purge);
do_housekeeping();
dead_session_purge(force_purge);
do_housekeeping();
+
+ pthread_mutex_lock(&ThreadCountMutex);
--active_workers;
--active_workers;
+ if (active_workers + config.c_min_workers < num_workers)
+ {
+ num_workers--;
+ pthread_mutex_unlock(&ThreadCountMutex);
+ return (NULL);
+ }
+ pthread_mutex_unlock(&ThreadCountMutex);
}
/* If control reaches this point, the server is shutting down */
}
/* If control reaches this point, the server is shutting down */
+ pthread_mutex_lock(&ThreadCountMutex);
--num_workers;
--num_workers;
+ pthread_mutex_unlock(&ThreadCountMutex);
return(NULL);
}
return(NULL);
}