From: Timo Sirainen Date: Wed, 3 Jun 2009 21:19:53 +0000 (-0400) Subject: log, lib-master: More fifo handling fixes. X-Git-Tag: 2.0.alpha1~614 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e3540e734a79fd4f971652925079c2e26a4b5524;p=thirdparty%2Fdovecot%2Fcore.git log, lib-master: More fifo handling fixes. --HG-- branch : HEAD --- diff --git a/src/lib-master/master-service.c b/src/lib-master/master-service.c index 3c4c20764a..2a5dea6036 100644 --- a/src/lib-master/master-service.c +++ b/src/lib-master/master-service.c @@ -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); diff --git a/src/log/log-connection.c b/src/log/log-connection.c index 5b29079c9d..eb7c1ff826 100644 --- a/src/log/log-connection.c +++ b/src/log/log-connection.c @@ -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); diff --git a/src/log/log-connection.h b/src/log/log-connection.h index c2abbe2d82..33b8df8ed6 100644 --- a/src/log/log-connection.h +++ b/src/log/log-connection.h @@ -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); diff --git a/src/log/main.c b/src/log/main.c index b7818735a7..db6293a346 100644 --- a/src/log/main.c +++ b/src/log/main.c @@ -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[])