]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
log, lib-master: More fifo handling fixes.
authorTimo Sirainen <tss@iki.fi>
Wed, 3 Jun 2009 21:19:53 +0000 (17:19 -0400)
committerTimo Sirainen <tss@iki.fi>
Wed, 3 Jun 2009 21:19:53 +0000 (17:19 -0400)
--HG--
branch : HEAD

src/lib-master/master-service.c
src/log/log-connection.c
src/log/log-connection.h
src/log/main.c

index 3c4c20764aa31a8b7265b2ee2d3fc2b2d16a197d..2a5dea6036e56f0d27e7110897eeb584bf243dbb 100644 (file)
@@ -488,11 +488,11 @@ static void master_service_listen(struct master_service_listener *l)
                   as the connection fd and stop the listener. */
                io_remove(&l->io);
                conn.fd = dup(l->fd);
+               conn.listen_fd = l->fd;
                if (conn.fd == -1) {
                        i_error("dup() failed: %m");
                        return;
                }
-               io_remove(&l->io);
        }
        conn.ssl = l->ssl;
        net_set_nonblock(conn.fd, TRUE);
index 5b29079c9d4d4b2d38d0d5a269e900e310988273..eb7c1ff826df244529ba1b9221a0d1f8dbc19bb7 100644 (file)
@@ -160,13 +160,10 @@ static bool log_connection_handshake(struct log_connection *log,
                                        handshake.prefix_len);
                *data += sizeof(handshake) + handshake.prefix_len;
        }
-       if (strcmp(log->prefix, MASTER_LOG_PREFIX_NAME) == 0) {
-               if (log->fd != MASTER_LISTEN_FD_FIRST) {
-                       i_error("Received master prefix in handshake "
-                               "from non-master fd %d", log->fd);
-                       return FALSE;
-               }
-               log->master = TRUE;
+       if (strcmp(log->prefix, MASTER_LOG_PREFIX_NAME) == 0 && !log->master) {
+               i_error("Received master prefix in handshake "
+                       "from non-master fd %d", log->fd);
+               return FALSE;
        }
        log->handshaked = TRUE;
        return TRUE;
@@ -202,7 +199,7 @@ static void log_connection_input(struct log_connection *log)
        }
 }
 
-struct log_connection *log_connection_create(int fd)
+struct log_connection *log_connection_create(int fd, bool master)
 {
        struct log_connection *log;
 
@@ -211,6 +208,7 @@ struct log_connection *log_connection_create(int fd)
        log->io = io_add(fd, IO_READ, log_connection_input, log);
        log->clients = hash_table_create(default_pool, default_pool, 0,
                                         NULL, NULL);
+       log->master = master;
        array_idx_set(&logs_by_fd, fd, &log);
 
        DLLIST_PREPEND(&log_connections, log);
index c2abbe2d820230eb46a9a3419397e2b2011a30c2..33b8df8ed60e1492222402874a003a0ae0d46c2f 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef LOG_CONNECTION_H
 #define LOG_CONNECTION_H
 
-struct log_connection *log_connection_create(int fd);
+struct log_connection *log_connection_create(int fd, bool master);
 void log_connection_destroy(struct log_connection *log);
 
 void log_connections_init(void);
index b7818735a7fa75cd44ff1fc28cc2167f0f083596..db6293a346211e6ea1dc96195e22c4451e39a833 100644 (file)
@@ -40,7 +40,9 @@ static void main_deinit(void)
 
 static void client_connected(const struct master_service_connection *conn)
 {
-       log_connection_create(conn->fd);
+       bool master = conn->listen_fd == MASTER_LISTEN_FD_FIRST;
+
+       log_connection_create(conn->fd, master);
 }
 
 int main(int argc, char *argv[])