From 95e5fb9cf533829b33ea87baa206a5fb2e1d00cf Mon Sep 17 00:00:00 2001 From: "Christopher J. Morrone" <morrone2@llnl.gov> Date: Tue, 5 Dec 2006 22:49:48 +0000 Subject: [PATCH] Fix to eio to handle POLLNVAL properly. --- src/common/eio.c | 12 ++++-------- src/common/eio.h | 10 ++++++++++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/common/eio.c b/src/common/eio.c index dce5443d2ed..22c587a0104 100644 --- a/src/common/eio.c +++ b/src/common/eio.c @@ -290,13 +290,7 @@ _poll_handle_event(short revents, eio_obj_t *obj, List objList) bool read_called = false; bool write_called = false; - if (revents & POLLNVAL) { - debug("POLLNVAL on fd %d, shutting down eio object", obj->fd); - obj->shutdown = true; - return; - } - - if (revents & POLLERR) { + if (revents & POLLERR || revents & POLLNVAL) { if (obj->ops->handle_error) { (*obj->ops->handle_error) (obj, objList); } else if (obj->ops->handle_read) { @@ -306,7 +300,9 @@ _poll_handle_event(short revents, eio_obj_t *obj, List objList) (*obj->ops->handle_write) (obj, objList); write_called = true; } else { - debug("No handler for POLLERR"); + debug("No handler for %s on fd %d", + revents & POLLERR ? "POLLERR" : "POLLNVAL", + obj->fd); obj->shutdown = true; } return; diff --git a/src/common/eio.h b/src/common/eio.h index 95f31acf4d7..83e660675dd 100644 --- a/src/common/eio.h +++ b/src/common/eio.h @@ -39,6 +39,16 @@ typedef struct eio_handle_components eio_handle_t; * * handle_*() functions also pass the List of io_obj's from the event loop * + * If either "handle_error" (for POLLERR and POLLNVAL) or "handle_close" + * (for POLLHUP) are not defined, the eio server will fallback to handle_read + * if defined, and fallback to handle_write if handle_read is not defined + * either. + * + * If there are no handlers at all when POLLERR or POLLNVAL occurs, the eio + * server will set the eio_obj_t shutdown flag to "true". Keep in mind + * that the shutdown flag is essentially just an advisory flag. The + * "readable" and "writable" functions have the final say over whether a + * file descriptor will continue to be polled. */ struct io_operations { bool (*readable )(eio_obj_t *); -- GitLab