mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-31 11:41:32 +01:00
agent: Better serialization for scdaemon access.
* agent/call-scd.c (unlock_scd): Move lock before accessing IN_USE. (wait_child_thread): Add log_info for Windows, and fixed log_error message. -- The old code is still valid with cooperate threads, but this is better. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
f12fcd9079
commit
483e63f9b5
@ -169,29 +169,25 @@ unlock_scd (ctrl_t ctrl, int rc)
|
||||
if (!rc)
|
||||
rc = gpg_error (GPG_ERR_INTERNAL);
|
||||
}
|
||||
err = npth_mutex_lock (&start_scd_lock);
|
||||
if (err)
|
||||
{
|
||||
log_error ("failed to acquire the start_scd lock: %s\n", strerror (err));
|
||||
return gpg_error (GPG_ERR_INTERNAL);
|
||||
}
|
||||
ctrl->scd_local->in_use = 0;
|
||||
if (ctrl->scd_local->invalid)
|
||||
{
|
||||
err = npth_mutex_lock (&start_scd_lock);
|
||||
if (err)
|
||||
{
|
||||
log_error ("failed to acquire the start_scd lock: %s\n",
|
||||
strerror (err));
|
||||
return gpg_error (GPG_ERR_INTERNAL);
|
||||
}
|
||||
|
||||
assuan_release (ctrl->scd_local->ctx);
|
||||
ctrl->scd_local->ctx = NULL;
|
||||
|
||||
err = npth_mutex_unlock (&start_scd_lock);
|
||||
if (err)
|
||||
{
|
||||
log_error ("failed to release the start_scd lock: %s\n",
|
||||
strerror (err));
|
||||
return gpg_error (GPG_ERR_INTERNAL);
|
||||
}
|
||||
ctrl->scd_local->invalid = 0;
|
||||
}
|
||||
err = npth_mutex_unlock (&start_scd_lock);
|
||||
if (err)
|
||||
{
|
||||
log_error ("failed to release the start_scd lock: %s\n", strerror (err));
|
||||
return gpg_error (GPG_ERR_INTERNAL);
|
||||
}
|
||||
ctrl->scd_local->invalid = 0;
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -219,6 +215,7 @@ wait_child_thread (void *arg)
|
||||
npth_unprotect ();
|
||||
WaitForSingleObject ((HANDLE)pid, INFINITE);
|
||||
npth_protect ();
|
||||
log_info ("scdaemon finished\n");
|
||||
#else
|
||||
int wstatus;
|
||||
pid_t pid = (pid_t)(uintptr_t)arg;
|
||||
@ -278,8 +275,8 @@ wait_child_thread (void *arg)
|
||||
|
||||
err = npth_mutex_unlock (&start_scd_lock);
|
||||
if (err)
|
||||
log_error ("failed to release the start_scd lock while"
|
||||
" doing the aliveness check: %s\n", strerror (err));
|
||||
log_error ("failed to release the start_scd lock after waitpid",
|
||||
strerror (err));
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user