Patch: General locking (was Possible deadlock and solution)

Matthias Andree matthias.andree at gmx.de
Tue Oct 1 15:25:17 CEST 2002


On Mon, 30 Sep 2002, Gyepi SAM wrote:

> +/*
> +* Acquires locks on multiple database.
> +*/
> +static void db_lock_list(void *vhandle_list[], int n, int type){
> +  int i;
> +  int cmd;
> +
> +  dbh_t *handle;
> +
> +  char *block_type[] = { "nonblocking", "blocking" };
> +  char *lock_type[]  = { "write", "read" };
> +
> +  for(;;){
> +    for(i = 0, cmd = F_SETLKW ; i < n; i++, cmd = F_SETLK){

Is this SETLKW/SETLK complexity necessary? Why not F_SETLK all over the
place?

> +    //sleep for short, random time between 1 microsecond and 1 second
> +    usleep((int) (1000.0*rand()/(RAND_MAX+1.0)));

Seems comment and code don't match.

Other than that and the code replication in the printf stuff, it looks
fine. Thanks!

-- 
Matthias Andree



More information about the bogofilter-dev mailing list