mirror of
git://git.gnupg.org/gnupg.git
synced 2024-11-09 21:28:51 +01:00
scd: Factor out scd_init_event function.
* scd/scdaemon.c (scd_init_event): New. -- Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
1695cf267e
commit
9aa6faaf10
@ -1026,7 +1026,36 @@ scd_get_socket_name (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifndef HAVE_W32_SYSTEM
|
#ifdef HAVE_W32_SYSTEM
|
||||||
|
/* Creat an event into E_P and sets EVENTS to watch by npth_eselect. */
|
||||||
|
void
|
||||||
|
scd_init_event (HANDLE *e_p, HANDLE events[2])
|
||||||
|
{
|
||||||
|
HANDLE h, h2;
|
||||||
|
SECURITY_ATTRIBUTES sa = { sizeof (SECURITY_ATTRIBUTES), NULL, TRUE};
|
||||||
|
|
||||||
|
events[0] = *e_p = INVALID_HANDLE_VALUE;
|
||||||
|
events[1] = INVALID_HANDLE_VALUE;
|
||||||
|
/* Create event for manual reset, initially non-signaled. Make it
|
||||||
|
* waitable and inheritable. */
|
||||||
|
h = CreateEvent (&sa, TRUE, FALSE, NULL);
|
||||||
|
if (!h)
|
||||||
|
log_error ("can't create scd event: %s\n", w32_strerror (-1) );
|
||||||
|
else if (!DuplicateHandle (GetCurrentProcess(), h,
|
||||||
|
GetCurrentProcess(), &h2,
|
||||||
|
EVENT_MODIFY_STATE|SYNCHRONIZE, TRUE, 0))
|
||||||
|
{
|
||||||
|
log_error ("setting synchronize for scd_kick_the_loop failed: %s\n",
|
||||||
|
w32_strerror (-1) );
|
||||||
|
CloseHandle (h);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CloseHandle (h);
|
||||||
|
events[0] = *e_p = h2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
static void
|
static void
|
||||||
handle_signal (int signo)
|
handle_signal (int signo)
|
||||||
{
|
{
|
||||||
@ -1302,31 +1331,7 @@ handle_connections (gnupg_fd_t listen_fd)
|
|||||||
npth_attr_setdetachstate (&tattr, NPTH_CREATE_DETACHED);
|
npth_attr_setdetachstate (&tattr, NPTH_CREATE_DETACHED);
|
||||||
|
|
||||||
#ifdef HAVE_W32_SYSTEM
|
#ifdef HAVE_W32_SYSTEM
|
||||||
{
|
scd_init_event (&the_event, events);
|
||||||
HANDLE h, h2;
|
|
||||||
SECURITY_ATTRIBUTES sa = { sizeof (SECURITY_ATTRIBUTES), NULL, TRUE};
|
|
||||||
|
|
||||||
events[0] = the_event = INVALID_HANDLE_VALUE;
|
|
||||||
events[1] = INVALID_HANDLE_VALUE;
|
|
||||||
/* Create event for manual reset, initially non-signaled. Make it
|
|
||||||
* waitable and inheritable. */
|
|
||||||
h = CreateEvent (&sa, TRUE, FALSE, NULL);
|
|
||||||
if (!h)
|
|
||||||
log_error ("can't create scd event: %s\n", w32_strerror (-1) );
|
|
||||||
else if (!DuplicateHandle (GetCurrentProcess(), h,
|
|
||||||
GetCurrentProcess(), &h2,
|
|
||||||
EVENT_MODIFY_STATE|SYNCHRONIZE, TRUE, 0))
|
|
||||||
{
|
|
||||||
log_error ("setting synchronize for scd_kick_the_loop failed: %s\n",
|
|
||||||
w32_strerror (-1) );
|
|
||||||
CloseHandle (h);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CloseHandle (h);
|
|
||||||
events[0] = the_event = h2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FD_ZERO (&fdset);
|
FD_ZERO (&fdset);
|
||||||
|
@ -138,6 +138,10 @@ struct server_control_s
|
|||||||
/*-- scdaemon.c --*/
|
/*-- scdaemon.c --*/
|
||||||
void scd_exit (int rc);
|
void scd_exit (int rc);
|
||||||
const char *scd_get_socket_name (void);
|
const char *scd_get_socket_name (void);
|
||||||
|
#ifdef HAVE_W32_SYSTEM
|
||||||
|
void scd_init_event (HANDLE *e_p, HANDLE events[2]);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*-- command.c --*/
|
/*-- command.c --*/
|
||||||
gpg_error_t initialize_module_command (void);
|
gpg_error_t initialize_module_command (void);
|
||||||
|
Loading…
Reference in New Issue
Block a user