git-svn: trunk@1631
Tomasz Kojm authored on 2005/06/23 23:00:08... | ... |
@@ -45,14 +45,12 @@ |
45 | 45 |
#define FALSE (0) |
46 | 46 |
#define TRUE (1) |
47 | 47 |
|
48 |
-volatile int progexit = 0; |
|
49 |
-static pthread_mutex_t exit_mutex = PTHREAD_MUTEX_INITIALIZER; |
|
50 |
-volatile int reload = 0; |
|
51 |
-volatile time_t reloaded_time = 0; |
|
52 |
-static pthread_mutex_t reload_mutex = PTHREAD_MUTEX_INITIALIZER; |
|
53 |
-volatile int sighup = 0; |
|
54 |
-static pthread_mutex_t session_mutex = PTHREAD_MUTEX_INITIALIZER; |
|
55 |
-volatile int session_count = 0; |
|
48 |
+int progexit = 0; |
|
49 |
+pthread_mutex_t exit_mutex; |
|
50 |
+int reload = 0; |
|
51 |
+time_t reloaded_time = 0; |
|
52 |
+pthread_mutex_t reload_mutex; |
|
53 |
+int sighup = 0; |
|
56 | 54 |
|
57 | 55 |
typedef struct client_conn_tag { |
58 | 56 |
int sd; |
... | ... |
@@ -60,7 +58,6 @@ typedef struct client_conn_tag { |
60 | 60 |
const struct cfgstruct *copt; |
61 | 61 |
struct cl_node *root; |
62 | 62 |
time_t root_timestamp; |
63 |
- time_t queue_time; |
|
64 | 63 |
const struct cl_limits *limits; |
65 | 64 |
int *socketds; |
66 | 65 |
int nsockets; |
... | ... |
@@ -78,24 +75,6 @@ void scanner_thread(void *arg) |
78 | 78 |
sigfillset(&sigset); |
79 | 79 |
pthread_sigmask(SIG_SETMASK, &sigset, NULL); |
80 | 80 |
|
81 |
- timeout = cfgopt(conn->copt, "MaxConnectionQueueTime")->numarg; |
|
82 |
- if(timeout && (conn->queue_time+timeout < time(NULL))) { |
|
83 |
- logg("^Aborting Stale connection request\n"); |
|
84 |
- close(conn->sd); |
|
85 |
- cl_free(conn->root); |
|
86 |
- free(conn); |
|
87 |
- return; |
|
88 |
- } |
|
89 |
- pthread_mutex_lock(&exit_mutex); |
|
90 |
- if(progexit) { |
|
91 |
- pthread_mutex_unlock(&exit_mutex); |
|
92 |
- logg("^Dropping connection request to exit\n"); |
|
93 |
- close(conn->sd); |
|
94 |
- cl_free(conn->root); |
|
95 |
- free(conn); |
|
96 |
- return; |
|
97 |
- } |
|
98 |
- pthread_mutex_unlock(&exit_mutex); |
|
99 | 81 |
timeout = cfgopt(conn->copt, "ReadTimeout")->numarg; |
100 | 82 |
if(!timeout) |
101 | 83 |
timeout = -1; |
... | ... |
@@ -124,52 +103,28 @@ void scanner_thread(void *arg) |
124 | 124 |
break; |
125 | 125 |
|
126 | 126 |
case COMMAND_SESSION: |
127 |
- if(!session) { |
|
128 |
- pthread_mutex_lock(&session_mutex); |
|
129 |
- session_count++; |
|
130 |
- if(cfgopt(conn->copt, "MaxThreads")->numarg <= session_count) { |
|
131 |
- logg("^Active sessions(%d) consuming all available threads(%d)\n", session_count, cfgopt(conn->copt, "MaxThreads")->numarg); |
|
132 |
- } |
|
133 |
- pthread_mutex_unlock(&session_mutex); |
|
134 |
- session = TRUE; |
|
135 |
- } |
|
127 |
+ session = TRUE; |
|
136 | 128 |
timeout = 5; |
137 | 129 |
break; |
138 | 130 |
|
139 | 131 |
case COMMAND_END: |
140 |
- if(session) { |
|
141 |
- pthread_mutex_lock(&session_mutex); |
|
142 |
- session_count--; |
|
143 |
- pthread_mutex_unlock(&session_mutex); |
|
144 |
- session = FALSE; |
|
145 |
- } |
|
132 |
+ session = FALSE; |
|
146 | 133 |
break; |
147 | 134 |
} |
148 | 135 |
if (session) { |
149 | 136 |
pthread_mutex_lock(&exit_mutex); |
150 | 137 |
if(progexit) { |
151 | 138 |
session = FALSE; |
152 |
- pthread_mutex_lock(&session_mutex); |
|
153 |
- --session_count; |
|
154 |
- pthread_mutex_unlock(&session_mutex); |
|
155 | 139 |
} |
156 | 140 |
pthread_mutex_unlock(&exit_mutex); |
157 | 141 |
pthread_mutex_lock(&reload_mutex); |
158 | 142 |
if (conn->root_timestamp != reloaded_time) { |
159 | 143 |
session = FALSE; |
160 |
- pthread_mutex_lock(&session_mutex); |
|
161 |
- --session_count; |
|
162 |
- pthread_mutex_unlock(&session_mutex); |
|
163 | 144 |
} |
164 | 145 |
pthread_mutex_unlock(&reload_mutex); |
165 | 146 |
} |
166 | 147 |
} while (session); |
167 | 148 |
|
168 |
- if(session) { |
|
169 |
- pthread_mutex_lock(&session_mutex); |
|
170 |
- --session_count; |
|
171 |
- pthread_mutex_unlock(&session_mutex); |
|
172 |
- } |
|
173 | 149 |
close(conn->sd); |
174 | 150 |
cl_free(conn->root); |
175 | 151 |
free(conn); |
... | ... |
@@ -264,7 +219,7 @@ static struct cl_node *reload_db(struct cl_node *root, const struct cfgstruct *c |
264 | 264 |
|
265 | 265 |
int acceptloop_th(int *socketds, int nsockets, struct cl_node *root, const struct cfgstruct *copt) |
266 | 266 |
{ |
267 |
- int new_sd, max_threads, max_queue_size, i; |
|
267 |
+ int new_sd, max_threads, i; |
|
268 | 268 |
unsigned int options = 0; |
269 | 269 |
threadpool_t *thr_pool; |
270 | 270 |
struct sigaction sigact; |
... | ... |
@@ -310,8 +265,6 @@ int acceptloop_th(int *socketds, int nsockets, struct cl_node *root, const struc |
310 | 310 |
logg("*Listening daemon: PID: %d\n", getpid()); |
311 | 311 |
max_threads = cfgopt(copt, "MaxThreads")->numarg; |
312 | 312 |
|
313 |
- max_queue_size = cfgopt(copt, "MaxConnectionQueueLength")->numarg; |
|
314 |
- |
|
315 | 313 |
if(cfgopt(copt, "ScanArchive")->enabled || cfgopt(copt, "ClamukoScanArchive")->enabled) { |
316 | 314 |
|
317 | 315 |
/* set up limits */ |
... | ... |
@@ -481,14 +434,14 @@ int acceptloop_th(int *socketds, int nsockets, struct cl_node *root, const struc |
481 | 481 |
|
482 | 482 |
idletimeout = cfgopt(copt, "IdleTimeout")->numarg; |
483 | 483 |
|
484 |
- if((thr_pool=thrmgr_new(max_threads, max_queue_size, idletimeout, scanner_thread)) == NULL) { |
|
484 |
+ if((thr_pool=thrmgr_new(max_threads, idletimeout, scanner_thread)) == NULL) { |
|
485 | 485 |
logg("!thrmgr_new failed\n"); |
486 | 486 |
exit(-1); |
487 | 487 |
} |
488 | 488 |
|
489 | 489 |
time(&start_time); |
490 | 490 |
|
491 |
- for(;;) { |
|
491 |
+ for(;;) { |
|
492 | 492 |
int socketd = socketds[0]; |
493 | 493 |
if(nsockets > 1) { |
494 | 494 |
int pollret = poll_fds(socketds, nsockets, -1); |
... | ... |
@@ -507,7 +460,7 @@ int acceptloop_th(int *socketds, int nsockets, struct cl_node *root, const struc |
507 | 507 |
#ifdef HAVE_STRERROR_R |
508 | 508 |
logg("!accept() failed: %s\n", strerror_r(errno, buff, BUFFSIZE)); |
509 | 509 |
#else |
510 |
- logg("!accept() failed: %d\n", errno); |
|
510 |
+ logg("!accept() failed\n"); |
|
511 | 511 |
#endif |
512 | 512 |
continue; |
513 | 513 |
} |
... | ... |
@@ -527,7 +480,6 @@ int acceptloop_th(int *socketds, int nsockets, struct cl_node *root, const struc |
527 | 527 |
client_conn->copt = copt; |
528 | 528 |
client_conn->root = cl_dup(root); |
529 | 529 |
client_conn->root_timestamp = reloaded_time; |
530 |
- time(&client_conn->queue_time); |
|
531 | 530 |
client_conn->limits = &limits; |
532 | 531 |
client_conn->socketds = socketds; |
533 | 532 |
client_conn->nsockets = nsockets; |
... | ... |
@@ -566,7 +518,7 @@ int acceptloop_th(int *socketds, int nsockets, struct cl_node *root, const struc |
566 | 566 |
root = reload_db(root, copt, FALSE); |
567 | 567 |
pthread_mutex_lock(&reload_mutex); |
568 | 568 |
reload = 0; |
569 |
- time((time_t *)&reloaded_time); |
|
569 |
+ time(&reloaded_time); |
|
570 | 570 |
pthread_mutex_unlock(&reload_mutex); |
571 | 571 |
#ifdef CLAMUKO |
572 | 572 |
if(cfgopt(copt, "ClamukoScanOnAccess")->enabled) { |
... | ... |
@@ -104,11 +104,6 @@ Maximum length the queue of pending connections may grow to. |
104 | 104 |
.br |
105 | 105 |
Default: 15 |
106 | 106 |
.TP |
107 |
-\fBMaxConnectionQueueTime NUMBER\fR |
|
108 |
-Maximum number of seconds a connection can be queued and unprocessed without being aborted when it finally comes time to process it. The value of zero disables the limit. |
|
109 |
-.br |
|
110 |
-Default: 20 |
|
111 |
-.TP |
|
112 | 107 |
\fBMaxThreads NUMBER\fR |
113 | 108 |
Maximal number of threads running at the same time. |
114 | 109 |
.br |
... | ... |
@@ -90,12 +90,6 @@ LocalSocket /tmp/clamd |
90 | 90 |
# Default: 15 |
91 | 91 |
#MaxConnectionQueueLength 30 |
92 | 92 |
|
93 |
-# Maximum number of seconds a connection can be queued and unprocessed without |
|
94 |
-# being aborted when it finally comes time to process it. The value of zero |
|
95 |
-# disables the limit. |
|
96 |
-# Default: 20 |
|
97 |
-#MaxConnectionQueueTime 30 |
|
98 |
- |
|
99 | 93 |
# Clamd uses FTP-like protocol to receive data from remote clients. |
100 | 94 |
# If you are using clamav-milter to balance load between remote clamd daemons |
101 | 95 |
# on firewall servers you may need to tune the options below. |
... | ... |
@@ -72,7 +72,6 @@ struct cfgstruct *getcfg(const char *cfgfile, int verbose) |
72 | 72 |
{"TCPSocket", OPT_NUM, -1, NULL, 0}, |
73 | 73 |
{"LocalSocket", OPT_STR, -1, NULL, 0}, |
74 | 74 |
{"MaxConnectionQueueLength", OPT_NUM, 15, NULL, 0}, |
75 |
- {"MaxConnectionQueueTime", OPT_NUM, 20, NULL, 0}, |
|
76 | 75 |
{"StreamMaxLength", OPT_COMPSIZE, 10485760, NULL, 0}, |
77 | 76 |
{"StreamMinPort", OPT_NUM, 1024, NULL, 0}, |
78 | 77 |
{"StreamMaxPort", OPT_NUM, 2048, NULL, 0}, |