mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
agent: Fix a race condition which results accessing finished scd.
* agent/call-daemon.c (daemon_start): Decision of connection/reuse of CTX and assignment to ->ctx should be done with the lock. -- When scdaemon is exiting and agent tries to spawn/connect/reconnect, there is a race condition between detecting finish of scd and spawn/connect/reconnect. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
fee890a2ab
commit
563bfbb0be
@ -469,13 +469,12 @@ daemon_start (enum daemon_type type, ctrl_t ctrl)
|
|||||||
}
|
}
|
||||||
|
|
||||||
leave:
|
leave:
|
||||||
rc = npth_mutex_unlock (&start_daemon_lock);
|
|
||||||
if (rc)
|
|
||||||
log_error ("failed to release the start_daemon lock: %s\n", strerror (rc));
|
|
||||||
|
|
||||||
xfree (abs_homedir);
|
xfree (abs_homedir);
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
|
rc = npth_mutex_unlock (&start_daemon_lock);
|
||||||
|
if (rc)
|
||||||
|
log_error ("failed to release the start_daemon lock: %s\n", strerror (rc));
|
||||||
daemon_unlock (type, ctrl, err);
|
daemon_unlock (type, ctrl, err);
|
||||||
if (ctx)
|
if (ctx)
|
||||||
assuan_release (ctx);
|
assuan_release (ctx);
|
||||||
@ -484,6 +483,9 @@ daemon_start (enum daemon_type type, ctrl_t ctrl)
|
|||||||
{
|
{
|
||||||
ctrl->d_local[type]->ctx = ctx;
|
ctrl->d_local[type]->ctx = ctx;
|
||||||
ctrl->d_local[type]->invalid = 0;
|
ctrl->d_local[type]->invalid = 0;
|
||||||
|
rc = npth_mutex_unlock (&start_daemon_lock);
|
||||||
|
if (rc)
|
||||||
|
log_error ("failed to release the start_daemon lock: %s\n", strerror (rc));
|
||||||
}
|
}
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user