]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Fixed log process after recent lib-master changes.
authorTimo Sirainen <tss@iki.fi>
Thu, 4 Jun 2009 16:52:14 +0000 (12:52 -0400)
committerTimo Sirainen <tss@iki.fi>
Thu, 4 Jun 2009 16:52:14 +0000 (12:52 -0400)
--HG--
branch : HEAD

src/log/log-connection.c
src/log/log-connection.h
src/log/main.c

index eb7c1ff826df244529ba1b9221a0d1f8dbc19bb7..fccb2cde0c43a86aaa7cbcc7b0efc2df5047389d 100644 (file)
@@ -24,6 +24,7 @@ struct log_connection {
        struct log_connection *prev, *next;
 
        int fd;
+       int listen_fd;
        struct io *io;
 
        char *prefix;
@@ -160,10 +161,13 @@ 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 && !log->master) {
-               i_error("Received master prefix in handshake "
-                       "from non-master fd %d", log->fd);
-               return FALSE;
+       if (strcmp(log->prefix, MASTER_LOG_PREFIX_NAME) == 0) {
+               if (log->listen_fd != MASTER_LISTEN_FD_FIRST) {
+                       i_error("Received master prefix in handshake "
+                               "from non-master fd %d", log->fd);
+                       return FALSE;
+               }
+               log->master = TRUE;
        }
        log->handshaked = TRUE;
        return TRUE;
@@ -199,17 +203,17 @@ static void log_connection_input(struct log_connection *log)
        }
 }
 
-struct log_connection *log_connection_create(int fd, bool master)
+struct log_connection *log_connection_create(int fd, int listen_fd)
 {
        struct log_connection *log;
 
        log = i_new(struct log_connection, 1);
        log->fd = fd;
+       log->listen_fd = listen_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);
+       array_idx_set(&logs_by_fd, listen_fd, &log);
 
        DLLIST_PREPEND(&log_connections, log);
        log_connection_input(log);
@@ -221,7 +225,7 @@ void log_connection_destroy(struct log_connection *log)
        struct hash_iterate_context *iter;
        void *key, *value;
 
-       array_idx_clear(&logs_by_fd, log->fd);
+       array_idx_clear(&logs_by_fd, log->listen_fd);
 
        DLLIST_REMOVE(&log_connections, log);
 
index 33b8df8ed60e1492222402874a003a0ae0d46c2f..93f8193187cf70171fc80ef9a056f310609699b2 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef LOG_CONNECTION_H
 #define LOG_CONNECTION_H
 
-struct log_connection *log_connection_create(int fd, bool master);
+struct log_connection *log_connection_create(int fd, int listen_fd);
 void log_connection_destroy(struct log_connection *log);
 
 void log_connections_init(void);
index db6293a346211e6ea1dc96195e22c4451e39a833..1bb431d61a5b1155b85329f4ee7ed5610199f489 100644 (file)
@@ -40,9 +40,7 @@ static void main_deinit(void)
 
 static void client_connected(const struct master_service_connection *conn)
 {
-       bool master = conn->listen_fd == MASTER_LISTEN_FD_FIRST;
-
-       log_connection_create(conn->fd, master);
+       log_connection_create(conn->fd, conn->listen_fd);
 }
 
 int main(int argc, char *argv[])