1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +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
parent 8c0ac05f06
commit 0a94582af5
No known key found for this signature in database
GPG Key ID: 640114AF89DE6054

View File

@ -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)