|
@@ -43,7 +43,8 @@ struct pir_process_st {
|
|
|
static void
|
|
|
pirprocess_stdoutcb(evutil_socket_t fd, short what, void *arg)
|
|
|
{
|
|
|
- pir_process_t handle = (pir_process_t)arg;
|
|
|
+ pir_process_t *handlep = (pir_process_t*)arg;
|
|
|
+ pir_process_t handle = *handlep;
|
|
|
|
|
|
if (!(what & EV_READ)) {
|
|
|
/* Not sure why we're here */
|
|
@@ -59,6 +60,7 @@ pirprocess_stdoutcb(evutil_socket_t fd, short what, void *arg)
|
|
|
handle->readleft = PIRPROCESS_HDR_SIZE;
|
|
|
handle->readstate = PIRPROCESS_READSTATE_HEADER;
|
|
|
(handle->msghandler)(NULL, NULL, 0);
|
|
|
+ hs_pirprocess_close(handlep);
|
|
|
return;
|
|
|
}
|
|
|
handle->readoff += res;
|
|
@@ -89,6 +91,7 @@ pirprocess_stdoutcb(evutil_socket_t fd, short what, void *arg)
|
|
|
handle->readleft = PIRPROCESS_HDR_SIZE;
|
|
|
handle->readstate = PIRPROCESS_READSTATE_HEADER;
|
|
|
(handle->msghandler)(NULL, NULL, 0);
|
|
|
+ hs_pirprocess_close(handlep);
|
|
|
return;
|
|
|
}
|
|
|
handle->readoff += res;
|
|
@@ -111,7 +114,8 @@ pirprocess_stdoutcb(evutil_socket_t fd, short what, void *arg)
|
|
|
static void
|
|
|
pirprocess_stdincb(evutil_socket_t fd, short what, void *arg)
|
|
|
{
|
|
|
- pir_process_t handle = (pir_process_t)arg;
|
|
|
+ pir_process_t *handlep = (pir_process_t*)arg;
|
|
|
+ pir_process_t handle = *handlep;
|
|
|
int res;
|
|
|
size_t bufsize = buf_datalen(handle->stdin_buf);
|
|
|
char *netbuf = NULL;
|
|
@@ -162,7 +166,8 @@ pirprocess_stdincb(evutil_socket_t fd, short what, void *arg)
|
|
|
static void
|
|
|
pirprocess_stderrcb(evutil_socket_t fd, short what, void *arg)
|
|
|
{
|
|
|
- pir_process_t handle = (pir_process_t)arg;
|
|
|
+ pir_process_t *handlep = (pir_process_t*)arg;
|
|
|
+ pir_process_t handle = *handlep;
|
|
|
|
|
|
if (!(what & EV_READ)) {
|
|
|
/* Not sure why we're here */
|
|
@@ -221,6 +226,7 @@ hs_pirprocess_close(pir_process_t *handlep)
|
|
|
event_free(handle->stderr_ev);
|
|
|
}
|
|
|
if (handle->process) {
|
|
|
+ log_info(LD_DIRSERV,"PIRPROCESS destroying subprocess");
|
|
|
tor_process_handle_destroy(handle->process, 1);
|
|
|
}
|
|
|
if (handle->loglabel) {
|
|
@@ -273,6 +279,7 @@ hs_pirprocess_poke(const char *path, const char *loglabel,
|
|
|
|
|
|
env = process_environment_make(env_vars);
|
|
|
|
|
|
+ log_info(LD_DIRSERV,"PIRPROCESS spawning subprocess");
|
|
|
res = tor_spawn_background(path, argv, env, &(handle->process));
|
|
|
|
|
|
SMARTLIST_FOREACH(env_vars, void *, x, tor_free(x));
|
|
@@ -290,13 +297,13 @@ hs_pirprocess_poke(const char *path, const char *loglabel,
|
|
|
/* Create a libevent event to listen to the PIR process' responses. */
|
|
|
handle->stdout_ev = event_new(tor_libevent_get_base(),
|
|
|
handle->process->stdout_pipe, EV_READ|EV_PERSIST,
|
|
|
- pirprocess_stdoutcb, handle);
|
|
|
+ pirprocess_stdoutcb, handlep);
|
|
|
event_add(handle->stdout_ev, NULL);
|
|
|
|
|
|
/* And one to listen to the PIR server's stderr. */
|
|
|
handle->stderr_ev = event_new(tor_libevent_get_base(),
|
|
|
handle->process->stderr_pipe, EV_READ|EV_PERSIST,
|
|
|
- pirprocess_stderrcb, handle);
|
|
|
+ pirprocess_stderrcb, handlep);
|
|
|
event_add(handle->stderr_ev, NULL);
|
|
|
|
|
|
/* And one for writability to the pir process' stdin, but don't add
|
|
@@ -305,7 +312,7 @@ hs_pirprocess_poke(const char *path, const char *loglabel,
|
|
|
handle->stderr_buf = buf_new();
|
|
|
handle->stdin_ev = event_new(tor_libevent_get_base(),
|
|
|
handle->process->stdin_pipe, EV_WRITE, pirprocess_stdincb,
|
|
|
- handle);
|
|
|
+ handlep);
|
|
|
|
|
|
handle->readstate = PIRPROCESS_READSTATE_HEADER;
|
|
|
handle->readoff = 0;
|