[or-cvs] Backport: Allow a few EINVALs from libevent before dying. ...

Nick Mathewson nickm at seul.org
Mon Jun 13 00:48:41 UTC 2005


Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv29451/src/or

Modified Files:
      Tag: tor-0_1_0-patches
	config.c main.c 
Log Message:
Backport: Allow a few EINVALs from libevent before dying.  Warn on kqueue with libevent before 1.1a

Index: config.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/config.c,v
retrieving revision 1.353.2.3
retrieving revision 1.353.2.4
diff -u -d -r1.353.2.3 -r1.353.2.4
--- config.c	9 Jun 2005 04:15:17 -0000	1.353.2.3
+++ config.c	13 Jun 2005 00:48:39 -0000	1.353.2.4
@@ -2667,7 +2667,8 @@
   tor_assert(m && v);
 
   if (!strcmp(m, "kqueue")) {
-    if (!strcmp(v, "1.0c")) {
+    if (!strcmp(v, "1.0c") || !strcmp(v, "1.0d") || !strcmp(v, "1.0e") ||
+        !strcmp(v, "1.1")) {
       buggy = 1;
     }
   } else if (!strcmp(m, "epoll")) {

Index: main.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/main.c,v
retrieving revision 1.505.2.2
retrieving revision 1.505.2.3
diff -u -d -r1.505.2.2 -r1.505.2.3
--- main.c	7 Jun 2005 17:34:40 -0000	1.505.2.2
+++ main.c	13 Jun 2005 00:48:39 -0000	1.505.2.3
@@ -769,6 +769,7 @@
 }
 
 static struct event *timeout_event = NULL;
+static int n_libevent_errors = 0;
 
 /** Libevent callback: invoked once every second. */
 static void second_elapsed_callback(int fd, short event, void *args)
@@ -840,6 +841,19 @@
            "Error from libevent when setting one-second timeout event");
 }
 
+/** Called when a possibly ignorable libevent error occurs; ensures that we
+ * don't get into an infinite loop by ignoring too many errors from
+ * libevent. */
+int
+got_libevent_error(void)
+{
+  if (++n_libevent_errors > 8) {
+    log_fn(LOG_ERR, "Too many libevent errors in one second; dying");
+    return -1;
+  }
+  return 0;
+}
+
 /** Called when we get a SIGHUP: reload configuration files and keys,
  * retry all connections, re-upload all descriptors, and so on. */
 static int do_hup(void) {
@@ -952,6 +966,12 @@
                tor_socket_strerror(e), e);
 #endif
         return -1;
+#ifndef MS_WINDOWS
+      } else if (e == EINVAL) {
+        log_fn(LOG_WARN, "EINVAL from libevent: should you upgrade libevent?");
+        if (got_libevent_error())
+          return -1;
+#endif
       } else {
         if (ERRNO_IS_EINPROGRESS(e))
           log_fn(LOG_WARN,"libevent poll returned EINPROGRESS? Please report.");



More information about the tor-commits mailing list