diff --git a/src/nwshare.c b/src/nwshare.c index 387df90..2560ac2 100644 --- a/src/nwshare.c +++ b/src/nwshare.c @@ -778,24 +778,27 @@ int share_handle_lock_sets(int type, int lock_flag, int timeout) SHARESET **pset = &first_set; while (*pset) { SHARESET *ps = *pset; - *pset = (*pset)->next; + if (type & ps->type) { if (ps->locked && (lock_flag < 0)) { if (!lock_unlock_pset(ps, -1)) ps->locked = 0; } else if ((!ps->locked) && lock_flag > -1){ if (lock_unlock_pset(ps, lock_flag)){ - /* remove all locks */ + /* release locks already acquired for this set operation */ share_handle_lock_sets(type, -1, 0); return(-1); } else ps->locked = 1; } - if (lock_flag == -2) { /* remove node */ + if (lock_flag == -2) { /* remove matching node */ + *pset = ps->next; xfree(ps->data); xfree(ps); - } - } + continue; + } + } + pset = &ps->next; } return(0); }