[dovecot-cvs] dovecot/src/auth auth-master-connection.c, 1.31,
1.32 auth-master-connection.h, 1.10, 1.11 main.c, 1.42, 1.43
cras at dovecot.org
cras at dovecot.org
Tue Apr 19 09:54:44 EEST 2005
- Previous message: [dovecot-cvs]
dovecot/src/auth db-ldap.c, 1.28, 1.29 db-ldap.h, 1.13,
1.14 passdb-ldap.c, 1.28, 1.29 userdb-ldap.c, 1.30, 1.31
- Next message: [dovecot-cvs] dovecot/src/auth Makefile.am, 1.45,
1.46 auth-client-connection.c, 1.35,
1.36 auth-client-connection.h, 1.9,
1.10 auth-master-connection.c, 1.32,
1.33 auth-master-connection.h, 1.11,
1.12 auth-master-listener.c, NONE, 1.1 auth-master-listener.h,
NONE, 1.1 auth-request-handler.c, 1.4,
1.5 auth-request-handler.h, 1.3, 1.4 auth-request.h, 1.14,
1.15 main.c, 1.43, 1.44
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /var/lib/cvs/dovecot/src/auth
In directory talvi:/tmp/cvs-serv5863
Modified Files:
auth-master-connection.c auth-master-connection.h main.c
Log Message:
Exit only if all master connections are lost, not only if one of them is.
Index: auth-master-connection.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/auth-master-connection.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- auth-master-connection.c 7 Mar 2005 20:21:52 -0000 1.31
+++ auth-master-connection.c 19 Apr 2005 06:54:41 -0000 1.32
@@ -34,9 +34,10 @@
struct auth_request *auth_request;
};
+static array_t ARRAY_DEFINE(master_connections,
+ struct auth_master_connection *);
+
static int master_output(void *context);
-static void auth_master_connection_close(struct auth_master_connection *conn);
-static int auth_master_connection_unref(struct auth_master_connection *conn);
static void auth_listener_destroy(struct auth_listener *l);
void auth_master_request_callback(const char *reply, void *context)
@@ -141,13 +142,13 @@
return;
case -1:
/* disconnected */
- auth_master_connection_close(conn);
+ auth_master_connection_destroy(conn);
return;
case -2:
/* buffer full */
i_error("BUG: Master sent us more than %d bytes",
(int)MAX_INBUF_SIZE);
- auth_master_connection_close(conn);
+ auth_master_connection_destroy(conn);
return;
}
@@ -162,7 +163,7 @@
AUTH_MASTER_PROTOCOL_MAJOR_VERSION) {
i_error("Master not compatible with this server "
"(mixed old and new binaries?)");
- auth_master_connection_close(conn);
+ auth_master_connection_destroy(conn);
return;
}
conn->version_received = TRUE;
@@ -186,7 +187,7 @@
t_pop();
if (!ret) {
- auth_master_connection_close(conn);
+ auth_master_connection_destroy(conn);
return;
}
}
@@ -199,7 +200,7 @@
if ((ret = o_stream_flush(conn->output)) < 0) {
/* transmit error, probably master died */
- auth_master_connection_close(conn);
+ auth_master_connection_destroy(conn);
return 1;
}
@@ -237,12 +238,12 @@
conn = i_new(struct auth_master_connection, 1);
conn->auth = auth;
- conn->refcount = 1;
conn->pid = (unsigned int)getpid();
conn->fd = fd;
conn->listeners_buf = buffer_create_dynamic(default_pool, 64);
if (fd != -1)
auth_master_connection_set_fd(conn, fd);
+ array_append(&master_connections, &conn, 1);
return conn;
}
@@ -259,30 +260,11 @@
(void)o_stream_send_str(conn->output, line);
}
-static void auth_master_connection_close(struct auth_master_connection *conn)
-{
- if (!standalone)
- io_loop_stop(ioloop);
-
- if (close(conn->fd) < 0)
- i_error("close(): %m");
- conn->fd = -1;
-
- i_stream_unref(conn->input);
- conn->input = NULL;
-
- o_stream_unref(conn->output);
- conn->output = NULL;
-
- if (conn->io != NULL) {
- io_remove(conn->io);
- conn->io = NULL;
- }
-}
-
void auth_master_connection_destroy(struct auth_master_connection *conn)
{
+ struct auth_master_connection *const *conns;
struct auth_listener **l;
+ unsigned int i, count;
if (conn->destroyed)
return;
@@ -290,8 +272,16 @@
auth_client_connections_deinit(conn);
- if (conn->fd != -1)
- auth_master_connection_close(conn);
+ if (conn->fd != -1) {
+ if (close(conn->fd) < 0)
+ i_error("close(): %m");
+ }
+ if (conn->input != NULL)
+ i_stream_unref(conn->input);
+ if (conn->output != NULL)
+ o_stream_unref(conn->output);
+ if (conn->io != NULL)
+ io_remove(conn->io);
while (conn->listeners_buf->used > 0) {
l = buffer_get_modifyable_data(conn->listeners_buf, NULL);
@@ -300,18 +290,17 @@
buffer_free(conn->listeners_buf);
conn->listeners_buf = NULL;
- auth_master_connection_unref(conn);
-}
-
-static int auth_master_connection_unref(struct auth_master_connection *conn)
-{
- if (--conn->refcount > 0)
- return TRUE;
-
- if (conn->output != NULL)
- o_stream_unref(conn->output);
+ conns = array_get(&master_connections, &count);
+ for (i = 0; i < count; i++) {
+ if (conns[i] == conn) {
+ array_delete(&master_connections, i, 1);
+ break;
+ }
+ }
+ if (!standalone && array_count(&master_connections) == 0)
+ io_loop_stop(ioloop);
+
i_free(conn);
- return FALSE;
}
static void auth_accept(void *context)
@@ -378,3 +367,30 @@
}
i_free(l);
}
+
+void auth_master_connections_send_handshake(void)
+{
+ struct auth_master_connection *const *conns;
+ unsigned int i, count;
+
+ conns = array_get(&master_connections, &count);
+ for (i = 0; i < count; i++)
+ auth_master_connection_send_handshake(conns[i]);
+}
+
+void auth_master_connections_init(void)
+{
+ ARRAY_CREATE(&master_connections, default_pool,
+ struct auth_master_connection *, 16);
+}
+
+void auth_master_connections_deinit(void)
+{
+ struct auth_master_connection *const *conns;
+ unsigned int i, count;
+
+ conns = array_get(&master_connections, &count);
+ for (i = count; i > 0; i--)
+ auth_master_connection_destroy(conns[i]);
+ array_free(&master_connections);
+}
Index: auth-master-connection.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/auth-master-connection.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- auth-master-connection.h 28 Feb 2005 22:19:21 -0000 1.10
+++ auth-master-connection.h 19 Apr 2005 06:54:41 -0000 1.11
@@ -29,13 +29,18 @@
struct auth_master_connection *
auth_master_connection_create(struct auth *auth, int fd);
-void auth_master_connection_send_handshake(struct auth_master_connection *conn);
void auth_master_connection_destroy(struct auth_master_connection *conn);
+void auth_master_connection_send_handshake(struct auth_master_connection *conn);
+void auth_master_connections_send_handshake(void);
+
void auth_master_request_callback(const char *reply, void *context);
void auth_master_connection_add_listener(struct auth_master_connection *conn,
int fd, const char *path,
enum listener_type type);
+void auth_master_connections_init(void);
+void auth_master_connections_deinit(void);
+
#endif
Index: main.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/main.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- main.c 7 Mar 2005 18:55:13 -0000 1.42
+++ main.c 19 Apr 2005 06:54:41 -0000 1.43
@@ -30,7 +30,6 @@
int standalone = FALSE, worker = FALSE;
time_t process_start_time;
-static buffer_t *masters_buf;
static struct auth *auth;
static struct auth_worker_client *worker_client;
@@ -169,7 +168,6 @@
LISTENER_CLIENT);
}
auth_client_connections_init(master);
- buffer_append(masters_buf, &master, sizeof(master));
t_pop();
}
}
@@ -186,7 +184,7 @@
auth = auth_preinit();
password_schemes_init();
- masters_buf = buffer_create_dynamic(default_pool, 64);
+ auth_master_connections_init();
if (!worker)
add_extra_listeners();
@@ -196,8 +194,7 @@
static void main_init(int nodaemon)
{
- struct auth_master_connection *master, **master_p;
- size_t i, size;
+ struct auth_master_connection *master;
process_start_time = ioloop_time;
lib_init_signals(sig_quit);
@@ -243,36 +240,23 @@
auth_master_connection_add_listener(master, CLIENT_LISTEN_FD,
NULL, LISTENER_CLIENT);
auth_client_connections_init(master);
- buffer_append(masters_buf, &master, sizeof(master));
}
/* everything initialized, notify masters that all is well */
- master_p = buffer_get_modifyable_data(masters_buf, &size);
- size /= sizeof(*master_p);
- for (i = 0; i < size; i++)
- auth_master_connection_send_handshake(master_p[i]);
+ auth_master_connections_send_handshake();
}
static void main_deinit(void)
{
- struct auth_master_connection **master;
- size_t i, size;
-
if (lib_signal_kill != 0)
i_warning("Killed with signal %d", lib_signal_kill);
if (worker_client != NULL)
auth_worker_client_destroy(worker_client);
- else {
+ else
auth_request_handler_flush_failures();
- master = buffer_get_modifyable_data(masters_buf, &size);
- size /= sizeof(*master);
- for (i = 0; i < size; i++)
- auth_master_connection_destroy(master[i]);
- }
- buffer_free(masters_buf);
-
+ auth_master_connections_deinit();
auth_request_handler_deinit();
auth_deinit(auth);
mech_deinit();
- Previous message: [dovecot-cvs]
dovecot/src/auth db-ldap.c, 1.28, 1.29 db-ldap.h, 1.13,
1.14 passdb-ldap.c, 1.28, 1.29 userdb-ldap.c, 1.30, 1.31
- Next message: [dovecot-cvs] dovecot/src/auth Makefile.am, 1.45,
1.46 auth-client-connection.c, 1.35,
1.36 auth-client-connection.h, 1.9,
1.10 auth-master-connection.c, 1.32,
1.33 auth-master-connection.h, 1.11,
1.12 auth-master-listener.c, NONE, 1.1 auth-master-listener.h,
NONE, 1.1 auth-request-handler.c, 1.4,
1.5 auth-request-handler.h, 1.3, 1.4 auth-request.h, 1.14,
1.15 main.c, 1.43, 1.44
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dovecot-cvs
mailing list