VLOG_DEFINE_THIS_MODULE(worker);
+/* ovs_assert() logs the assertion message and logging sometimes goes through a
+ * worker, so using ovs_assert() in this source file could cause recursion. */
+#undef ovs_assert
+#define ovs_assert use_assert_instead_of_ovs_assert_in_this_module
+
/* Header for an RPC request. */
struct worker_request {
size_t request_len; /* Length of the payload in bytes. */
xset_nonblocking(work_fds[0]);
xset_nonblocking(work_fds[1]);
+ /* Don't let the worker process own the responsibility to delete
+ * the pidfile. Register it again after the fork. */
+ remove_pidfile_from_unlink();
if (!fork_and_clean_up()) {
/* In child (worker) process. */
daemonize_post_detach();
}
/* In parent (main) process. */
+ add_pidfile_to_unlink();
close(work_fds[1]);
client_sock = work_fds[0];
rxbuf_init(&client_rx);
} while (error == EINTR);
if (error) {
worker_broke();
- VLOG_ABORT("poll failed (%s)", strerror(error));
+ VLOG_ABORT("poll failed (%s)", ovs_strerror(error));
}
}
}
worker_request_func *request_cb,
worker_reply_func *reply_cb, void *aux)
{
+ static bool recursing = false;
struct worker_request rq;
struct iovec *all_iovs;
int error;
assert(worker_is_running());
+ assert(!recursing);
+ recursing = true;
rq.request_len = iovec_len(iovs, n_iovs);
rq.request_cb = request_cb;
error = worker_send_iovec(all_iovs, n_iovs + 1, fds, n_fds);
if (error) {
worker_broke();
- VLOG_ABORT("send failed (%s)", strerror(error));
+ VLOG_ABORT("send failed (%s)", ovs_strerror(error));
}
free(all_iovs);
+
+ recursing = false;
}
/* Closes the client socket, if any, so that worker_is_running() will return
if (error == EPIPE) {
/* Parent probably died. Continue processing any RPCs still buffered,
* to avoid missing log messages. */
- VLOG_INFO("send failed (%s)", strerror(error));
+ VLOG_INFO("send failed (%s)", ovs_strerror(error));
} else if (error) {
- VLOG_ABORT("send failed (%s)", strerror(error));
+ VLOG_FATAL("send failed (%s)", ovs_strerror(error));
}
free(all_iovs);
/* Main process closed the IPC socket. Exit cleanly. */
break;
} else if (error != EAGAIN) {
- VLOG_ABORT("RPC receive failed (%s)", strerror(error));
+ VLOG_FATAL("RPC receive failed (%s)", ovs_retval_to_string(error));
}
poll_fd_wait(server_sock, POLLIN);
}
}
}
-
- return EAGAIN;
}
static struct iovec *