Fix some startup-related glitches.
authorMichael Poole <mdpoole@troilus.org>
Wed, 4 Oct 2006 01:32:57 +0000 (01:32 +0000)
committerMichael Poole <mdpoole@troilus.org>
Wed, 4 Oct 2006 01:32:57 +0000 (01:32 +0000)
src/ioset.h (ioset_update): Declare new function.

src/ioset.c (ioset_init): If we have an engine, return early.
  (ioset_add): If no engine, try to initialize.
  (ioset_update): New function.
git-archimport-id: srvx@srvx.net--2006/srvx--devo--1.3--patch-52

ChangeLog
src/ioset.c
src/ioset.h

index 16645a000adc1a1d5ae1dce0dc739ca69d5c585f..b375385299bb2c533226ec79c1b8724cbb14ef4a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,23 @@
 # arch-tag: automatic-ChangeLog--srvx@srvx.net--2006/srvx--devo--1.3
 #
 
+2006-10-04 01:32:57 GMT        Michael Poole <mdpoole@troilus.org>     patch-52
+
+    Summary:
+      Fix some startup-related glitches.
+    Revision:
+      srvx--devo--1.3--patch-52
+
+    src/ioset.h (ioset_update): Declare new function.
+    
+    src/ioset.c (ioset_init): If we have an engine, return early.
+      (ioset_add): If no engine, try to initialize.
+      (ioset_update): New function.
+
+    modified files:
+     ChangeLog src/ioset.c src/ioset.h
+
+
 2006-10-04 01:23:10 GMT        Michael Poole <mdpoole@troilus.org>     patch-51
 
     Summary:
index a66af6f8b8fbb8badf2db3e20f71fbf4c98693d2..72204135e8388589bfc7094ca2ec2f9bf47e8eb0 100644 (file)
@@ -93,7 +93,8 @@ extern struct io_engine io_engine_select;
 void
 ioset_init(void)
 {
-    assert(engine == NULL);
+    if (engine) /* someone beat us to it */
+        return;
 
 #if WITH_IOSET_KQUEUE
     if (!engine && io_engine_kqueue.init())
@@ -133,6 +134,8 @@ ioset_add(int fd) {
         log_module(MAIN_LOG, LOG_ERROR, "Somebody called ioset_add(%d) on a negative fd!", fd);
         return 0;
     }
+    if (!engine)
+        ioset_init();
     res = calloc(1, sizeof(*res));
     if (!res)
         return 0;
@@ -269,6 +272,10 @@ ioset_connect(struct sockaddr *local, unsigned int sa_size, const char *peer, un
     return io_fd;
 }
 
+void ioset_update(struct io_fd *fd) {
+    engine->update(fd);
+}
+
 static void
 ioset_try_write(struct io_fd *fd) {
     int res;
index be27332b1f820c6153e2af520fba25188bcae0e9..48e692453cc3a333d5bf653f016fbd977b374a24 100644 (file)
@@ -52,6 +52,7 @@ void ioset_init(void);
 struct io_fd *ioset_add(int fd);
 struct io_fd *ioset_listen(struct sockaddr *local, unsigned int sa_size, void *data, void (*accept_cb)(struct io_fd *listener, struct io_fd *new_connect));
 struct io_fd *ioset_connect(struct sockaddr *local, unsigned int sa_size, const char *hostname, unsigned int port, int blocking, void *data, void (*connect_cb)(struct io_fd *fd, int error));
+void ioset_update(struct io_fd *fd);
 void ioset_run(void);
 void ioset_write(struct io_fd *fd, const char *buf, unsigned int nbw);
 int ioset_printf(struct io_fd *fd, const char *fmt, ...) PRINTF_LIKE(2, 3);