aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2024-09-20 01:39:35 +0000
committerWerner Koch <[email protected]>2024-09-20 10:07:45 +0000
commitc98385d311ca37e1863d0e42ebf7bbc6b68efe35 (patch)
treee9084479545bd28aac0648710418c0bfc89c7e9a
parentdoc: Update NEWS (diff)
downloadgnupg-c98385d311ca37e1863d0e42ebf7bbc6b68efe35.tar.gz
gnupg-c98385d311ca37e1863d0e42ebf7bbc6b68efe35.zip
scd: Fix DEVINFO, allowing no clients which watch the change.
* scd/app.c [POSIX] (struct mrsw_lock): Add notify_watchers. (card_list_signal): Only when watchers wait, kick by write(2). (card_list_wait): Increment/decrement notify_watchers field. -- GnuPG-bug-id: 7151 Signed-off-by: NIIBE Yutaka <[email protected]>
-rw-r--r--scd/app.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/scd/app.c b/scd/app.c
index 3e300fbaa..3a66256bc 100644
--- a/scd/app.c
+++ b/scd/app.c
@@ -58,6 +58,7 @@ struct mrsw_lock
HANDLE the_event;
#else
int notify_pipe[2];
+ int notify_watchers;
#endif
};
@@ -380,7 +381,10 @@ card_list_signal (void)
log_error ("SetEvent for card_list_signal failed: %s\n",
w32_strerror (-1));
#else
- write (card_list_lock.notify_pipe[1], "", 1);
+ npth_mutex_lock (&card_list_lock.lock);
+ if (card_list_lock.notify_watchers)
+ write (card_list_lock.notify_pipe[1], "", 1);
+ npth_mutex_unlock (&card_list_lock.lock);
#endif
}
@@ -400,7 +404,7 @@ card_list_wait (ctrl_t ctrl)
npth_mutex_lock (&card_list_lock.lock);
card_list_lock.writer_active--;
npth_cond_broadcast (&card_list_lock.cond);
-
+ card_list_lock.notify_watchers++;
npth_mutex_unlock (&card_list_lock.lock);
while (1)
@@ -448,7 +452,7 @@ card_list_wait (ctrl_t ctrl)
}
npth_mutex_lock (&card_list_lock.lock);
-
+ card_list_lock.notify_watchers--;
card_list_lock.num_writers_waiting++;
while (card_list_lock.num_readers_active
|| card_list_lock.writer_active)