SOURCES: tpop3d-libevent.patch - ready for wider testing

arekm arekm at pld-linux.org
Sat Jun 3 23:43:42 CEST 2006


Author: arekm                        Date: Sat Jun  3 21:43:42 2006 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- ready for wider testing

---- Files affected:
SOURCES:
   tpop3d-libevent.patch (1.2 -> 1.3) 

---- Diffs:

================================================================
Index: SOURCES/tpop3d-libevent.patch
diff -u SOURCES/tpop3d-libevent.patch:1.2 SOURCES/tpop3d-libevent.patch:1.3
--- SOURCES/tpop3d-libevent.patch:1.2	Sat Jun  3 18:10:49 2006
+++ SOURCES/tpop3d-libevent.patch	Sat Jun  3 23:43:37 2006
@@ -1,6 +1,6 @@
 diff -urN tpop3d-1.5.3.org/configure.in tpop3d-1.5.3/configure.in
---- tpop3d-1.5.3.org/configure.in	2006-06-02 10:37:54.000000000 +0200
-+++ tpop3d-1.5.3/configure.in	2006-06-02 11:10:12.000000000 +0200
+--- tpop3d-1.5.3.org/configure.in	2006-06-03 23:40:00.000000000 +0200
++++ tpop3d-1.5.3/configure.in	2006-06-03 23:40:37.000000000 +0200
 @@ -16,6 +16,8 @@
  
  AC_DEFINE_UNQUOTED(TPOP3D_VERSION, "$VERSION", [The tpop3d version number])
@@ -11,8 +11,8 @@
  
  dnl The various authentication options.
 diff -urN tpop3d-1.5.3.org/connection.c tpop3d-1.5.3/connection.c
---- tpop3d-1.5.3.org/connection.c	2006-06-02 10:37:54.000000000 +0200
-+++ tpop3d-1.5.3/connection.c	2006-06-03 13:00:02.000000000 +0200
+--- tpop3d-1.5.3.org/connection.c	2006-06-03 23:40:00.000000000 +0200
++++ tpop3d-1.5.3/connection.c	2006-06-03 23:40:37.000000000 +0200
 @@ -38,6 +38,8 @@
  
  extern int verbose;
@@ -53,9 +53,18 @@
      if (c->a) authcontext_delete(c->a);
      if (c->m) (c->m)->delete(c->m);
  
+@@ -264,7 +274,7 @@
+ /* connection_freeze:
+  * Mark a connection as frozen. */
+ void connection_freeze(connection c) {
+-    c->frozenuntil = time(NULL) + 3;
++    c->frozenuntil = 0; // time(NULL) + 3;
+ }
+ 
+ /* pop3_commands:
 diff -urN tpop3d-1.5.3.org/connection.h tpop3d-1.5.3/connection.h
 --- tpop3d-1.5.3.org/connection.h	2003-01-09 23:59:37.000000000 +0100
-+++ tpop3d-1.5.3/connection.h	2006-06-03 14:23:41.000000000 +0200
++++ tpop3d-1.5.3/connection.h	2006-06-03 23:40:37.000000000 +0200
 @@ -35,6 +35,7 @@
  
  typedef struct _connection {
@@ -70,7 +79,7 @@
       * handling. */
 -    void (*pre_select)(connection c, int *n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds);
 -    
-+    short (*pre_event)(connection c);
++    short (*reschedule_event)(connection c);
 +
      /* post_select:
       * Do handling after select has completed. Returns 1 if new data have been
@@ -83,7 +92,7 @@
       * Shut down the connection. Returns zero on success, IOABS_WOULDBLOCK if
 diff -urN tpop3d-1.5.3.org/ioabs_tcp.c tpop3d-1.5.3/ioabs_tcp.c
 --- tpop3d-1.5.3.org/ioabs_tcp.c	2003-09-30 20:45:46.000000000 +0200
-+++ tpop3d-1.5.3/ioabs_tcp.c	2006-06-03 14:23:59.000000000 +0200
++++ tpop3d-1.5.3/ioabs_tcp.c	2006-06-03 23:40:37.000000000 +0200
 @@ -25,6 +25,7 @@
  /* ioabs_tcp_shutdown:
   * Shut down the socket connection. */
@@ -97,7 +106,7 @@
  /* ioabs_tcp_pre_select:
   * Simple pre-select handling for TCP. */
 -static void ioabs_tcp_pre_select(connection c, int *n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds) {
-+static short ioabs_tcp_pre_event(connection c) {
++static short ioabs_tcp_reschedule_event(connection c) {
      struct ioabs_tcp *io;
 +    short want_event = EV_READ; /* always want to read */
      io = (struct ioabs_tcp*)c->io;
@@ -144,14 +153,14 @@
      io->und.immediate_write = ioabs_tcp_immediate_write;
 -    io->und.pre_select      = ioabs_tcp_pre_select;
 -    io->und.post_select     = ioabs_tcp_post_select;
-+    io->und.pre_event       = ioabs_tcp_pre_event;
++    io->und.reschedule_event       = ioabs_tcp_reschedule_event;
 +    io->und.post_event      = ioabs_tcp_post_event;
      io->und.shutdown        = ioabs_tcp_shutdown;
      io->und.destroy         = ioabs_tcp_destroy;
      return io;
 diff -urN tpop3d-1.5.3.org/ioabs_tls.c tpop3d-1.5.3/ioabs_tls.c
---- tpop3d-1.5.3.org/ioabs_tls.c	2006-06-02 10:37:54.000000000 +0200
-+++ tpop3d-1.5.3/ioabs_tls.c	2006-06-03 14:40:32.000000000 +0200
+--- tpop3d-1.5.3.org/ioabs_tls.c	2006-06-03 23:40:00.000000000 +0200
++++ tpop3d-1.5.3/ioabs_tls.c	2006-06-03 23:40:37.000000000 +0200
 @@ -44,6 +44,7 @@
  /* underlying_shutdown CONNECTION
   * Shut down the underlying transport for CONNECTION. */
@@ -165,7 +174,7 @@
  /* ioabs_tls_pre_select:
   * Pre-select handling for TLS, taking account of the rehandshaking nonsense. */
 -static void ioabs_tls_pre_select(connection c, int *n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds) {
-+static short ioabs_tls_pre_event(connection c) {
++static short ioabs_tls_reschedule_event(connection c) {
      struct ioabs_tls *io;
      io = (struct ioabs_tls*)c->io;
 +    short want_event = EV_READ; /* always want to read */
@@ -209,14 +218,14 @@
      io->und.immediate_write = ioabs_tls_immediate_write;
 -    io->und.pre_select      = ioabs_tls_pre_select;
 -    io->und.post_select     = ioabs_tls_post_select;
-+    io->und.pre_event       = ioabs_tls_pre_event;
++    io->und.reschedule_event       = ioabs_tls_reschedule_event;
 +    io->und.post_event      = ioabs_tls_post_event;
      io->und.shutdown        = ioabs_tls_shutdown;
      io->und.destroy         = ioabs_tls_destroy;
  
 diff -urN tpop3d-1.5.3.org/listener.c tpop3d-1.5.3/listener.c
 --- tpop3d-1.5.3.org/listener.c	2003-11-14 19:08:29.000000000 +0100
-+++ tpop3d-1.5.3/listener.c	2006-06-02 11:10:25.000000000 +0200
++++ tpop3d-1.5.3/listener.c	2006-06-03 23:40:37.000000000 +0200
 @@ -42,6 +42,8 @@
  
  #include "util.h"
@@ -248,7 +257,7 @@
      if (L->have_re)
 diff -urN tpop3d-1.5.3.org/listener.h tpop3d-1.5.3/listener.h
 --- tpop3d-1.5.3.org/listener.h	2003-01-09 23:59:37.000000000 +0100
-+++ tpop3d-1.5.3/listener.h	2006-06-02 11:10:25.000000000 +0200
++++ tpop3d-1.5.3/listener.h	2006-06-03 23:40:37.000000000 +0200
 @@ -12,6 +12,8 @@
  #define __LISTENER_H_
  
@@ -266,22 +275,10 @@
  } *listener;
  
  /* the arguments of the constructor vary according to the particular
-diff -urN tpop3d-1.5.3.org/maildir.c tpop3d-1.5.3/maildir.c
---- tpop3d-1.5.3.org/maildir.c	2006-06-02 10:37:54.000000000 +0200
-+++ tpop3d-1.5.3/maildir.c	2006-06-02 11:10:25.000000000 +0200
-@@ -360,7 +360,7 @@
- 
-     gettimeofday(&tv2, NULL);
-     f = (float)(tv2.tv_sec - tv1.tv_sec) + 1e-6 * (float)(tv2.tv_usec - tv1.tv_usec);
--    log_print(LOG_DEBUG, "maildir_new: scanned maildir %s (%d messages) in %0.3fs", dirname, (int)M->num, f);
-+    log_print(LOG_NOTICE, "maildir_new: scanned maildir %s (%d messages) in %0.3fs", dirname, (int)M->num, f);
-     
-     return M;
- 
 diff -urN tpop3d-1.5.3.org/main.c tpop3d-1.5.3/main.c
---- tpop3d-1.5.3.org/main.c	2006-06-02 10:37:54.000000000 +0200
-+++ tpop3d-1.5.3/main.c	2006-06-02 11:10:25.000000000 +0200
-@@ -473,6 +483,9 @@
+--- tpop3d-1.5.3.org/main.c	2006-06-03 23:40:00.000000000 +0200
++++ tpop3d-1.5.3/main.c	2006-06-03 23:40:37.000000000 +0200
+@@ -483,6 +483,9 @@
          }
      }
  
@@ -292,8 +289,8 @@
       * The syntax for these is <addr>[:port][(domain)]. */
      s = config_get_string("listen-address");
 diff -urN tpop3d-1.5.3.org/netloop.c tpop3d-1.5.3/netloop.c
---- tpop3d-1.5.3.org/netloop.c	2006-06-02 10:37:54.000000000 +0200
-+++ tpop3d-1.5.3/netloop.c	2006-06-03 18:00:03.000000000 +0200
+--- tpop3d-1.5.3.org/netloop.c	2006-06-03 23:40:00.000000000 +0200
++++ tpop3d-1.5.3/netloop.c	2006-06-03 23:41:32.000000000 +0200
 @@ -30,6 +30,7 @@
  
  #include <sys/socket.h>
@@ -353,7 +350,7 @@
              struct sockaddr_in sin, sinlocal;
              size_t l = sizeof(sin);
              static int tcp_send_buf = -1;
-@@ -185,19 +173,39 @@
+@@ -185,19 +173,25 @@
  
              if (errno != EAGAIN && errno != EINTR)
                  log_print(LOG_ERR, "net_loop: accept: %m");
@@ -365,44 +362,32 @@
 -/* connections_pre_select:
 - * Called before the main select(2) so connections can be polled. */
 -static void connections_pre_select(int *n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds) {
-+/* connections_pre_event:
-+ * reschedule some events */
-+static void connections_pre_event(int fd, short event_type, void *arg) {
-     connection *J;
+-    connection *J;
 -    for (J = connections; J < connections + max_connections; ++J)
-+    short want_event;
-+    struct event *ev = arg;
-+    struct timeval tv = {0};
-+
-+    for (J = connections; J < connections + max_connections; ++J) {
-+       connection c = *J;
-         /* Don't add frozen connections to the select masks. */
+-        /* Don't add frozen connections to the select masks. */
 -        if (*J && !connection_isfrozen(*J) && (*J)->cstate != closed)
 -            (*J)->io->pre_select(*J, n, readfds, writefds, exceptfds);
-+       if (c && !connection_isfrozen(c) && c->cstate != closed) {
-+            want_event = c->io->pre_event(c);
++/* connections_reschedule_event:
++ * reschedule some events */
++static void connections_reschedule_event(connection c) {
++    short want_event;
++
++    /* Don't add frozen connections to the select masks. */
++    if (c && !connection_isfrozen(c) && c->cstate != closed) {
++	    want_event = c->io->reschedule_event(c);
 +	    /* update if required events are not pending */
 +	    if ((want_event & EV_READ && !event_pending(&c->ev, EV_READ, NULL)) 
 +			    || (want_event & EV_WRITE && !event_pending(&c->ev, EV_WRITE, NULL))) {
 +		    event_del(&c->ev);
-+		    event_set(&c->ev, (*J)->s, want_event|EV_PERSIST, connection_post_event, (void *)c);
++		    event_set(&c->ev, c->s, want_event|EV_PERSIST, connection_post_event, (void *)c);
 +		    if (event_add(&c->ev, NULL) == -1)
-+			    log_print(LOG_ERR, "connections_pre_event: event_add: %m");
++			    log_print(LOG_ERR, "connections_reschedule_event: event_add: %m");
 +	    }
-+       }
 +    }
-+
-+    if (!evtimer_pending(ev, &tv)) {
-+	    tv.tv_sec = 1;  /* must be smaller than timeout */
-+	    evtimer_del(ev);
-+	    evtimer_set(ev, connections_pre_event, (void *)ev);
-+	    evtimer_add(ev, &tv);
-+    }
-+
  }
  
  /* fork_child CONNECTION
-@@ -380,27 +388,13 @@
+@@ -380,27 +374,13 @@
   * running/closing/closed state machine around and reading and writing the I/O
   * buffers. We need to try to parse commands when it's indicated that data have
   * been read, and react to the changed state of any connection. */
@@ -434,7 +419,7 @@
  
          if (r && !connection_isfrozen(c)) {
              /*
-@@ -438,20 +432,12 @@
+@@ -438,20 +418,12 @@
  
                  if (!c || c->do_shutdown)
                      break;
@@ -460,16 +445,13 @@
  
          /* Timeout handling. */
          if (timeout_seconds && (time(NULL) > (c->idlesince + timeout_seconds))) {
-@@ -497,21 +483,14 @@
-                 }
-                 log_print(LOG_INFO, _("connections_post_select: client %s: finished session for `%s' with %s"), c->idstr, c->a->user, c->a->auth);
+@@ -499,19 +471,12 @@
              }
--            log_print(LOG_INFO, _("connections_post_select: client %s: disconnected; %d/%d bytes read/written"), c->idstr, c->nrd, c->nwr);
-+            log_print(LOG_NOTICE, _("connections_post_select: client %s: disconnected; %d/%d bytes read/written"), c->idstr, c->nrd, c->nwr);
+             log_print(LOG_NOTICE, _("connections_post_select: client %s: disconnected; %d/%d bytes read/written"), c->idstr, c->nrd, c->nwr);
  
 -/*            remove_connection(c);*/
 -            connections[i] = NULL;
-+		remove_connection(c);
++            remove_connection(c);
              connection_delete(c);
              /* If this is a child process, we exit now. */
              if (post_fork)
@@ -484,7 +466,7 @@
  }
  
  /* net_loop
-@@ -520,6 +499,7 @@
+@@ -520,6 +485,7 @@
  sig_atomic_t foad = 0, restart = 0; /* Flags used to indicate that we should exit or should re-exec. */
  
  void net_loop(void) {
@@ -492,24 +474,12 @@
      connection *J;
  #ifdef AUTH_OTHER
      extern pid_t auth_other_childdied;
-@@ -528,6 +508,8 @@
-     extern pid_t child_died;
-     extern int child_died_signal;
-     sigset_t chmask;
-+    struct event ev;
-+    struct timeval tv = {0};
-     
-     sigemptyset(&chmask);
-     sigaddset(&chmask, SIGCHLD);
-@@ -537,32 +519,16 @@
+@@ -537,32 +503,12 @@
      connections = (connection*)xcalloc(max_connections, sizeof(connection*));
  
      log_print(LOG_INFO, _("net_loop: tpop3d version %s successfully started"), TPOP3D_VERSION);
+-    
 +
-+    tv.tv_sec = 1;  /* must be smaller than timeout */
-+    evtimer_set(&ev, connections_pre_event, (void *)&ev);
-+    evtimer_add(&ev, &tv);
-     
      /* Main select() loop */
      while (!foad) {
 -        fd_set readfds, writefds;
@@ -542,7 +512,7 @@
          
 diff -urN tpop3d-1.5.3.org/signals.c tpop3d-1.5.3/signals.c
 --- tpop3d-1.5.3.org/signals.c	2003-07-18 10:26:00.000000000 +0200
-+++ tpop3d-1.5.3/signals.c	2006-06-02 11:10:25.000000000 +0200
++++ tpop3d-1.5.3/signals.c	2006-06-03 23:40:37.000000000 +0200
 @@ -95,6 +95,9 @@
  /* terminate_signal_handler:
   * Signal handler to handle orderly termination of the program. */
@@ -597,7 +567,7 @@
  
 diff -urN tpop3d-1.5.3.org/signals.h tpop3d-1.5.3/signals.h
 --- tpop3d-1.5.3.org/signals.h	2003-01-09 23:59:39.000000000 +0100
-+++ tpop3d-1.5.3/signals.h	2006-06-02 11:10:25.000000000 +0200
++++ tpop3d-1.5.3/signals.h	2006-06-03 23:40:37.000000000 +0200
 @@ -17,5 +17,6 @@
  void die_signal_handler(const int i);
  void child_signal_handler(const int i);
@@ -605,3 +575,4 @@
 +int event_sigcb_handler(void);
  
  #endif /* __SIGNALS_H_ */
+
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/SOURCES/tpop3d-libevent.patch?r1=1.2&r2=1.3&f=u



More information about the pld-cvs-commit mailing list