struct event io_ev;
struct rspamd_worker *wrk;
gpointer ud;
+ gint attached_fd;
struct rspamd_control_reply_elt *prev, *next;
};
{
struct rspamd_control_reply_elt *elt = ud;
struct rspamd_control_session *session;
+ guchar fdspace[CMSG_SPACE(sizeof (int))];
+ struct iovec iov;
+ struct msghdr msg;
+ gssize r;
session = elt->ud;
-
- if (read (elt->wrk->control_pipe[0], &elt->reply, sizeof (elt->reply)) !=
- sizeof (elt->reply)) {
+ elt->attached_fd = -1;
+
+ iov.iov_base = &elt->reply;
+ iov.iov_len = sizeof (elt->reply);
+ memset (&msg, 0, sizeof (msg));
+ msg.msg_control = fdspace;
+ msg.msg_controllen = sizeof (fdspace);
+ msg.msg_iov = &iov;
+ msg.msg_iovlen = 1;
+
+ r = recvmsg (fd, &msg, 0);
+ if (r == -1) {
msg_err ("cannot read request from the worker %P (%s): %s",
elt->wrk->pid, g_quark_to_string (elt->wrk->type), strerror (errno));
}
+ else if (r >= (gssize)sizeof (elt->reply)) {
+ if (msg.msg_controllen >= CMSG_SPACE(sizeof (int))) {
+ elt->attached_fd = *(int *) CMSG_DATA(CMSG_FIRSTHDR (&msg));
+ }
+ }
session->replies_remain --;
event_del (&elt->io_ev);