From: Marko Kreen Date: Fri, 16 Jan 2009 12:18:24 +0000 (+0000) Subject: sbuf_close: dont retry event_del() if it fails, just proceed with cleanup. X-Git-Tag: pgbouncer_1_3_rc1~11 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cdf2f665e6f3516718823b7f06dc87e423850e9e;p=pgbouncer sbuf_close: dont retry event_del() if it fails, just proceed with cleanup. The retry could have been bug in pgbouncer - although then the question is that how to survive ENOMEM from event handlers that may need allocation on event_del(). But this does not explain why it fails first time. Seems there is something funny going on in libevent. --- diff --git a/src/sbuf.c b/src/sbuf.c index f8dcb61..e46b8d1 100644 --- a/src/sbuf.c +++ b/src/sbuf.c @@ -236,14 +236,20 @@ bool sbuf_continue_with_callback(SBuf *sbuf, sbuf_libevent_cb user_cb) return true; } -/* socket cleanup & close */ +/* socket cleanup & close: keeps .handler and .arg values */ bool sbuf_close(SBuf *sbuf) { - /* keep handler & arg values */ if (sbuf->sock > 0) { + /* event_del() acts funny occasionally, debug it */ + errno = 0; if (event_del(&sbuf->ev) < 0) { - log_warning("event_del: %s", strerror(errno)); - return false; + if (errno) + log_warning("event_del: %s", strerror(errno)); + else + log_warning("event_del: libevent error"); + + /* we can retry whole sbuf_close() if needed */ + /* if (errno == ENOMEM) return false; */ } safe_close(sbuf->sock); }