Signed-off-by: Angus Salkeld asalkeld@redhat.com --- lib/ipc_us.c | 14 ++++++++------ lib/ipcs.c | 6 ++---- tests/check_ipc.c | 1 + 3 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/lib/ipc_us.c b/lib/ipc_us.c index df4f735..08bedd7 100644 --- a/lib/ipc_us.c +++ b/lib/ipc_us.c @@ -191,14 +191,11 @@ retry_recv: if (result == -1) { return -errno; } -#if defined(QB_SOLARIS) || defined(QB_BSD) || defined(QB_DARWIN) - /* On many OS poll never return POLLHUP or POLLERR. - * EOF is detected when recvmsg return 0. - */ if (result == 0) { - return -errno; //ENOTCONN + qb_util_log(LOG_DEBUG, + "recv(fd %d) got 0 bytes assuming ENOTCONN", s); + return -ENOTCONN; } -#endif
processed += result; if (processed != len) { @@ -225,6 +222,7 @@ qb_ipc_us_recv_ready(struct qb_ipc_one_way * one_way, int32_t ms_timeout) } else if (poll_events == -1) { return -errno; } else if (poll_events == 1 && (ufds.revents & (POLLERR | POLLHUP))) { + qb_util_log(LOG_DEBUG, "poll(fd %d) got POLLHUP", one_way->u.us.sock); return -ENOTCONN; } return 0; @@ -251,6 +249,8 @@ retry_recv: } } if (result == 0) { + qb_util_log(LOG_DEBUG, "recv(fd %d) got 0 bytes assuming ENOTCONN", + one_way->u.us.sock); return -ENOTCONN; } if (result == -1) { @@ -289,6 +289,8 @@ retry_recv: } } if (result == 0) { + qb_util_log(LOG_DEBUG, "recv(fd %d) got 0 bytes assuming ENOTCONN", + one_way->u.us.sock); return -ENOTCONN; } if (result == -1) { diff --git a/lib/ipcs.c b/lib/ipcs.c index efc31d1..33a887b 100644 --- a/lib/ipcs.c +++ b/lib/ipcs.c @@ -598,14 +598,12 @@ _process_request_(struct qb_ipcs_connection *c, int32_t ms_timeout) } res = size; goto cleanup; - } - c->stats.requests++; - - if (hdr->id == QB_IPC_MSG_DISCONNECT) { + } else if (size == 0 || hdr->id == QB_IPC_MSG_DISCONNECT) { qb_util_log(LOG_DEBUG, "client requesting a disconnect"); qb_ipcs_disconnect(c); res = -ESHUTDOWN; } else { + c->stats.requests++; res = c->service->serv_fns.msg_process(c, hdr, hdr->size); /* 0 == good, negative == backoff */ if (res < 0) { diff --git a/tests/check_ipc.c b/tests/check_ipc.c index 8e0d3a3..191d005 100644 --- a/tests/check_ipc.c +++ b/tests/check_ipc.c @@ -697,6 +697,7 @@ main(void) qb_log_filter_ctl(QB_LOG_STDERR, QB_LOG_FILTER_ADD, QB_LOG_FILTER_FILE, "*", LOG_TRACE); qb_log_ctl(QB_LOG_STDERR, QB_LOG_CONF_ENABLED, QB_TRUE); + qb_log_format_set(QB_LOG_STDERR, "[%p] %f:%l %b");
srunner_run_all(sr, CK_VERBOSE); number_failed = srunner_ntests_failed(sr);