On Thu, Apr 12, 2007 at 10:25:41AM +0400, Aleksey Kuznetsov wrote:
> Да, действительно cgpav при подключенном clamav занимает 80-90 процентов
> процессора!-(,
Вот patch относительно cgpav 1.4 (хак с SOLARIS можно вернуть обратно), смысл первой правки - если нет заданий, то не циклимся как сумасшедшие, а просто спим; вторая - не дёргать malloc()/free() на каждый чих.
Если бы clamav-cgp.c поддерживал STREAM вмест[ое] со SCAN и умел балансировать нагрузку - цены бы ему не было :-)))
ANDY diff -rbc cgpav-1.4/cgpav.c cgpav-1.3c-DEMOS/cgpav.c
*** cgpav-1.4/cgpav.c Thu Jun 30 08:19:46 2005 --- cgpav-1.3c-DEMOS/cgpav.c Thu Dec 9 18:50:01 2004
/* just to avoid warnings */ pid = 0; spam_score = 0.0f; spam_threshold = 0.0f; - result = 0; ! while (requests_pending ! #ifndef SOLARIS /* bug in Solaris with SIGCHLD */ ! && (childs < sett->max_childs) ! #endif ! ) { if (!(mess = queue_get_next_entry())) break; /* theoretically this shouldn't --- 301,314 ---- int continue_scan = 1; /* what to do after virus scanning */ float spam_score; /* counted spam score */ float spam_threshold; /* when score over it spam detected */ ! int result = 0; /* just to avoid warnings */ pid = 0; spam_score = 0.0f; spam_threshold = 0.0f; ! while (requests_pending && (childs < sett->max_childs)) { if (!(mess = queue_get_next_entry())) break; /* theoretically this shouldn't
} /* while */
!
}
} /* while */ ! if(result == 0) /* Nothing usefull was done */ ! usleep(500); /* Sleep to avoid needless loop */}
/* strip ending '\n' and '\r' */ ! if ((char_ptr = strchr(input_str, '\r'))) ! *char_ptr = '\0'; ! if ((char_ptr = strchr(input_str, '\n'))) *char_ptr = '\0'; /* parse input string, put it to the queue */ --- 614,620 ---- if (fgets(input_str, MAX_INPUT_LEN, stdin)) { /* strip ending '\n' and '\r' */ ! if ((char_ptr = strpbrk(input_str, "\r\n"))) *char_ptr = '\0'; /* parse input string, put it to the queue */
if (seqnum && char_ptr) { if (filename && !strcasecmp(char_ptr, "FILE")) { ! dir_filename = (char *)malloc(strlen(sett->cgpro_home) ! + 1 + strlen(filename) ! + 1); ! if (dir_filename) { ! sprintf(dir_filename, "%s/%s", sett->cgpro_home, ! filename); queue_add_entry(seqnum, dir_filename); ! free(dir_filename); ! } ! else { ! printf("%s REJECTED \"Can't allocate memory " ! "for object.Will try later. \"\n", seqnum); fflush(stdout); ! syslog(LOG_ERR, ! "Can't allocate memory for object. Rejecting message: %s", ! filename); } } else if (filename && !strcasecmp(char_ptr, "INTF")) {--- 624,641 ----
if (seqnum && char_ptr) { if (filename && !strcasecmp(char_ptr, "FILE")) { ! char dir_filename[1024]; ! ! if(strlen(sett->cgpro_home) + strlen(filename) + 2 < sizeof(dir_filename)) { ! strcpy(dir_filename, sett->cgpro_home); ! strcat(dir_filename, "/"); ! strcat(dir_filename, filename); queue_add_entry(seqnum, dir_filename); ! } else { ! printf("%s OK\n", seqnum); fflush(stdout); ! syslog(LOG_ERR, "Long file name: %100.100s/%100.100s", ! sett->cgpro_home, filename); } } else if (filename && !strcasecmp(char_ptr, "INTF")) {
/* tidy queue */ queue_tidy(); ! queue_tidy(); } /* end of the main cycle */
/* tidy queue */ queue_tidy(); ! /* queue_tidy(); */ } /* end of the main cycle */Получено Thu Apr 12 09:16:10 2007
Этот архив был сгенерирован hypermail 2.1.8 : Thu 12 Apr 2007 - 14:13:40 MSD