if (cmd->cmd.on_fork.state == child_dead) {
/* We need to remove stale worker */
child = g_hash_table_lookup (srv->workers,
- GSIZE_TO_POINTER (cmd->cmd.on_fork.ppid));
+ GSIZE_TO_POINTER (cmd->cmd.on_fork.cpid));
if (child == NULL) {
msg_err ("cannot find child for a forked process %P (%P parent)",
REF_RELEASE (child->cf);
g_hash_table_remove (srv->workers,
- GSIZE_TO_POINTER (cmd->cmd.on_fork.ppid));
+ GSIZE_TO_POINTER (cmd->cmd.on_fork.cpid));
g_free (child);
}
else {
/* We still need to call on_complete callback */
rspamd_lua_call_on_complete (cbdata->L, cbdata,
"Worker has died without reply", NULL, 0);
+ event_del (&cbdata->ev);
}
/* Free structures */
- event_del (&cbdata->ev);
close (cbdata->sp[0]);
- close (cbdata->sp[1]);
luaL_unref (L, LUA_REGISTRYINDEX, cbdata->func_cbref);
luaL_unref (L, LUA_REGISTRYINDEX, cbdata->cb_cbref);
g_string_free (cbdata->io_buf, TRUE);
struct rspamd_lua_process_cbdata *cbdata = ud;
gssize r;
- if (cbdata->io_buf->len < sizeof (guint64)) {
+ if (cbdata->sz == (guint64)-1) {
guint64 sz;
/* We read size of reply + flags first */
if (r == 0) {
rspamd_lua_call_on_complete (cbdata->L, cbdata,
"Unexpected EOF", NULL, 0);
+ event_del (&cbdata->ev);
+ cbdata->replied = TRUE;
kill (cbdata->cpid, SIGTERM);
return;
else {
rspamd_lua_call_on_complete (cbdata->L, cbdata,
strerror (errno), NULL, 0);
+ event_del (&cbdata->ev);
+ cbdata->replied = TRUE;
kill (cbdata->cpid, SIGTERM);
return;
if (r == 0) {
rspamd_lua_call_on_complete (cbdata->L, cbdata,
"Unexpected EOF", NULL, 0);
+ event_del (&cbdata->ev);
+ cbdata->replied = TRUE;
kill (cbdata->cpid, SIGTERM);
return;
else {
rspamd_lua_call_on_complete (cbdata->L, cbdata,
strerror (errno), NULL, 0);
+ event_del (&cbdata->ev);
+ cbdata->replied = TRUE;
kill (cbdata->cpid, SIGTERM);
return;
NULL, cbdata->io_buf->str, cbdata->io_buf->len);
}
+ event_del (&cbdata->ev);
+ cbdata->replied = TRUE;
+
/* Write reply to the child */
rspamd_socket_blocking (cbdata->sp[0]);
memset (rep, 0, sizeof (rep));
cbdata->wrk = w;
cbdata->L = L;
cbdata->ev_base = actx->ev_base;
+ cbdata->sz = (guint64)-1;
pid = fork ();