From cfde1247f0065bde73359cf4476d06a44bda2e1e Mon Sep 17 00:00:00 2001 From: Mario Fetka Date: Fri, 29 May 2026 23:09:01 +0200 Subject: [PATCH] nwshare: preserve synchronization set entries Keep synchronization set entries linked while handling Lock, Release, and Clear Set operations. The Novell SDK documents the set-oriented synchronization calls as operating on the caller task table: Log File and Log Logical Record add entries, Lock Set locks the logged entries, Release Set unlocks them while keeping them logged for future Lock Set calls, and Clear Set unlocks and removes them. share_handle_lock_sets() already encoded that semantic split with lock_flag -1 for release and -2 for clear, but its iterator unlinked each entry before checking whether it should be removed. That meant even Lock Set and Release Set walked the table destructively, and non-matching set types could be lost while operating on another set family. Only unlink entries when processing a matching Clear Set operation. Leave entries in place for Lock Set and Release Set, and advance the list normally for non-matching entries. This fixes the shared set iterator used by the documented File Set and Logical Record Set endpoints; it does not change the low-level locking primitives. --- src/nwshare.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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); }