1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-11-10 21:38:50 +01:00

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>
This commit is contained in:
NIIBE Yutaka 2024-09-20 10:39:35 +09:00 committed by Werner Koch
parent f1e42cdf53
commit c98385d311
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -58,6 +58,7 @@ struct mrsw_lock
HANDLE the_event; HANDLE the_event;
#else #else
int notify_pipe[2]; int notify_pipe[2];
int notify_watchers;
#endif #endif
}; };
@ -380,7 +381,10 @@ card_list_signal (void)
log_error ("SetEvent for card_list_signal failed: %s\n", log_error ("SetEvent for card_list_signal failed: %s\n",
w32_strerror (-1)); w32_strerror (-1));
#else #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 #endif
} }
@ -400,7 +404,7 @@ card_list_wait (ctrl_t ctrl)
npth_mutex_lock (&card_list_lock.lock); npth_mutex_lock (&card_list_lock.lock);
card_list_lock.writer_active--; card_list_lock.writer_active--;
npth_cond_broadcast (&card_list_lock.cond); npth_cond_broadcast (&card_list_lock.cond);
card_list_lock.notify_watchers++;
npth_mutex_unlock (&card_list_lock.lock); npth_mutex_unlock (&card_list_lock.lock);
while (1) while (1)
@ -448,7 +452,7 @@ card_list_wait (ctrl_t ctrl)
} }
npth_mutex_lock (&card_list_lock.lock); npth_mutex_lock (&card_list_lock.lock);
card_list_lock.notify_watchers--;
card_list_lock.num_writers_waiting++; card_list_lock.num_writers_waiting++;
while (card_list_lock.num_readers_active while (card_list_lock.num_readers_active
|| card_list_lock.writer_active) || card_list_lock.writer_active)