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:
parent
8c0ac05f06
commit
0a94582af5
10
scd/app.c
10
scd/app.c
@ -59,6 +59,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
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -381,7 +382,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
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -401,7 +405,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)
|
||||||
@ -449,7 +453,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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user