Hello Trog, Wednesday, April 6, 2005, 12:27:13 PM, you wrote:
T> On Wed, 2005-04-06 at 10:19 +0200, Thomas Lamy wrote: >> Joanna Roman wrote: >> > Hi What would happen if the clamd is notified by >> > freshdb to reload the db when the clamd is in the >> > middle of scanning something. I have not read that >> > part of the code yet. But if you know the answer on >> > top of your head, pls inform me. >> > >> > >> AFAIR the thread manager (main thread) wait for all workers to finish >> (and suspends worker creation) on reload event, going back to normal >> operation after the reload has finished. T> Thats correct for the current release. T> The CVS code currently uses ref counting to overcome this limitation, so T> when a reload is requested, a new signature tree is generated, and the T> old one is free'd when all current scanning has finished. T> -trog In my project called Qavird I do switching of bases the following way: case QAVIRD_CMD_AVBASERELOAD: { struct Qavird_info new_state_info; struct cl_node * new_cl_root_node = NULL; struct cl_node * old_node = cl_root_node; /* 1) load new database into separate memory */ ....... ....... printf("Engine rebuilt succesfully\n"); /* 2) switch engine to a new database */ pthread_rwlock_wrlock( &cl_root_node_rwlock ); { cl_root_node = new_cl_root_node; new_state_info.virfound = state_info.virfound; new_state_info.fdone = state_info.fdone; new_state_info.startup = state_info.startup; memcpy(&state_info,&new_state_info,sizeof(struct Qavird_info)); } pthread_rwlock_unlock( &cl_root_node_rwlock ); printf("Successfully switched to a reloaded database\n"); /* 3) free old database */ cl_free(old_node); retval = QAV_CLEAN; break; } while all the scanning threads currently running use pthread_rwlock_rdlock( &cl_root_rwlock ) ... pthread_rwlock_unlock(...) clause to access root node. So multiple scanner threads are allowed to access the tree simultaneously while they all be prevented from accessing root node for a short period of time while the pointers are switched. I hope it'll help in some way when further developing clamd. -- Best regards, -=MikeP=- mailto:[EMAIL PROTECTED] _______________________________________________ http://lurker.clamav.net/list/clamav-devel.html