diff options
author | NIIBE Yutaka <gniibe@fsij.org> | 2024-09-20 03:39:35 +0200 |
---|---|---|
committer | NIIBE Yutaka <gniibe@fsij.org> | 2024-09-20 03:39:35 +0200 |
commit | 0a94582af5b1ed263db00dfeb26585f8dcd88a73 (patch) | |
tree | dfa48e8c60ed2e070ac108dbf7e3d2cf8e75fbb4 /scd | |
parent | speedo: Make use of wget more robust (diff) | |
download | gnupg2-0a94582af5b1ed263db00dfeb26585f8dcd88a73.tar.xz gnupg2-0a94582af5b1ed263db00dfeb26585f8dcd88a73.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 <gniibe@fsij.org>
Diffstat (limited to 'scd')
-rw-r--r-- | scd/app.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -59,6 +59,7 @@ struct mrsw_lock HANDLE the_event; #else int notify_pipe[2]; + int notify_watchers; #endif }; @@ -381,7 +382,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 } @@ -401,7 +405,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) @@ -449,7 +453,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) |