]> granicus.if.org Git - pgbouncer/commitdiff
sbuf_close: dont retry event_del() if it fails, just proceed with cleanup.
authorMarko Kreen <markokr@gmail.com>
Fri, 16 Jan 2009 12:18:24 +0000 (12:18 +0000)
committerMarko Kreen <markokr@gmail.com>
Fri, 16 Jan 2009 12:18:24 +0000 (12:18 +0000)
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.

src/sbuf.c

index f8dcb61c0953acb8eea3260971edb8e72a27c724..e46b8d1d6ea74b66d0dd6d7355b0edc420aba0f7 100644 (file)
@@ -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);
        }