| ... | ... |
@@ -1,3 +1,8 @@ |
| 1 |
+Sun Oct 29 19:45:07 CET 2006 (tk) |
|
| 2 |
+--------------------------------- |
|
| 3 |
+ * clamd: change stack size at the right place (closes bug#103) |
|
| 4 |
+ Patch from Jonathan Chen <jon+clamav*spock.org> |
|
| 5 |
+ |
|
| 1 | 6 |
Sun Oct 29 19:28:20 CET 2006 (tk) |
| 2 | 7 |
--------------------------------- |
| 3 | 8 |
* configure: make user/group check more precise (closes bug#41) |
| ... | ... |
@@ -255,7 +255,6 @@ int acceptloop_th(int *socketds, int nsockets, struct cl_node *root, unsigned in |
| 255 | 255 |
#endif |
| 256 | 256 |
mode_t old_umask; |
| 257 | 257 |
struct cl_limits limits; |
| 258 |
- pthread_attr_t thattr; |
|
| 259 | 258 |
#ifndef C_WINDOWS |
| 260 | 259 |
sigset_t sigset; |
| 261 | 260 |
#endif |
| ... | ... |
@@ -424,9 +423,6 @@ int acceptloop_th(int *socketds, int nsockets, struct cl_node *root, unsigned in |
| 424 | 424 |
logg("Self checking every %d seconds.\n", selfchk);
|
| 425 | 425 |
} |
| 426 | 426 |
|
| 427 |
- pthread_attr_init(&thattr); |
|
| 428 |
- pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_DETACHED); |
|
| 429 |
- |
|
| 430 | 427 |
if(cfgopt(copt, "ClamukoScanOnAccess")->enabled) |
| 431 | 428 |
#ifdef CLAMUKO |
| 432 | 429 |
{
|
| ... | ... |
@@ -476,18 +472,6 @@ int acceptloop_th(int *socketds, int nsockets, struct cl_node *root, unsigned in |
| 476 | 476 |
} |
| 477 | 477 |
#endif |
| 478 | 478 |
|
| 479 |
-#if defined(C_BIGSTACK) || defined(C_BSD) |
|
| 480 |
- /* |
|
| 481 |
- * njh@bandsman.co.uk: |
|
| 482 |
- * libclamav/scanners.c uses a *huge* buffer |
|
| 483 |
- * (128K not BUFSIZ from stdio.h). |
|
| 484 |
- * We need to allow for that. |
|
| 485 |
- */ |
|
| 486 |
- pthread_attr_getstacksize(&thattr, &stacksize); |
|
| 487 |
- logg("*set stacksize to %u\n", stacksize + SCANBUFF + 64 * 1024);
|
|
| 488 |
- pthread_attr_setstacksize(&thattr, stacksize + SCANBUFF + 64 * 1024); |
|
| 489 |
-#endif |
|
| 490 |
- |
|
| 491 | 479 |
pthread_mutex_init(&exit_mutex, NULL); |
| 492 | 480 |
pthread_mutex_init(&reload_mutex, NULL); |
| 493 | 481 |
|
| ... | ... |
@@ -134,6 +134,9 @@ void thrmgr_destroy(threadpool_t *threadpool) |
| 134 | 134 |
threadpool_t *thrmgr_new(int max_threads, int idle_timeout, void (*handler)(void *)) |
| 135 | 135 |
{
|
| 136 | 136 |
threadpool_t *threadpool; |
| 137 |
+#if defined(C_BIGSTACK) || defined(C_BSD) |
|
| 138 |
+ size_t stacksize; |
|
| 139 |
+#endif |
|
| 137 | 140 |
|
| 138 | 141 |
if (max_threads <= 0) {
|
| 139 | 142 |
return NULL; |
| ... | ... |
@@ -179,6 +182,14 @@ threadpool_t *thrmgr_new(int max_threads, int idle_timeout, void (*handler)(void |
| 179 | 179 |
free(threadpool); |
| 180 | 180 |
return NULL; |
| 181 | 181 |
} |
| 182 |
+ |
|
| 183 |
+#if defined(C_BIGSTACK) || defined(C_BSD) |
|
| 184 |
+ pthread_attr_getstacksize(&(threadpool->pool_attr), &stacksize); |
|
| 185 |
+ stacksize = stacksize + 64 * 1024; |
|
| 186 |
+ if (stacksize < 1048576) stacksize = 1048576; /* at least 1MB please */ |
|
| 187 |
+ logg("Set stacksize to %u\n", stacksize);
|
|
| 188 |
+ pthread_attr_setstacksize(&(threadpool->pool_attr), stacksize); |
|
| 189 |
+#endif |
|
| 182 | 190 |
threadpool->state = POOL_VALID; |
| 183 | 191 |
|
| 184 | 192 |
return threadpool; |