charon-cmd: use a copy of pid in initiate callback
When cancelling a connection that gets established, cmd_connection_t gets freed before terminate() is called. This results in kill()ing invalid PID.
This commit is contained in:
parent
e044a1a9e5
commit
47ec2e407b
|
@ -115,9 +115,9 @@ struct private_cmd_connection_t {
|
|||
/**
|
||||
* Shut down application
|
||||
*/
|
||||
static void terminate(private_cmd_connection_t *this)
|
||||
static void terminate(pid_t pid)
|
||||
{
|
||||
kill(this->pid, SIGUSR1);
|
||||
kill(pid, SIGUSR1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -329,17 +329,18 @@ static job_requeue_t initiate(private_cmd_connection_t *this)
|
|||
{
|
||||
peer_cfg_t *peer_cfg;
|
||||
child_cfg_t *child_cfg;
|
||||
pid_t pid = this->pid;
|
||||
|
||||
if (!this->host)
|
||||
{
|
||||
DBG1(DBG_CFG, "unable to initiate, missing --host option");
|
||||
terminate(this);
|
||||
terminate(pid);
|
||||
return JOB_REQUEUE_NONE;
|
||||
}
|
||||
if (!this->identity)
|
||||
{
|
||||
DBG1(DBG_CFG, "unable to initiate, missing --identity option");
|
||||
terminate(this);
|
||||
terminate(pid);
|
||||
return JOB_REQUEUE_NONE;
|
||||
}
|
||||
|
||||
|
@ -348,7 +349,7 @@ static job_requeue_t initiate(private_cmd_connection_t *this)
|
|||
if (!add_auth_cfgs(this, peer_cfg))
|
||||
{
|
||||
peer_cfg->destroy(peer_cfg);
|
||||
terminate(this);
|
||||
terminate(pid);
|
||||
return JOB_REQUEUE_NONE;
|
||||
}
|
||||
|
||||
|
@ -358,7 +359,7 @@ static job_requeue_t initiate(private_cmd_connection_t *this)
|
|||
if (charon->controller->initiate(charon->controller, peer_cfg, child_cfg,
|
||||
controller_cb_empty, NULL, 0) != SUCCESS)
|
||||
{
|
||||
terminate(this);
|
||||
terminate(pid);
|
||||
}
|
||||
return JOB_REQUEUE_NONE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue