[dovecot-cvs] dovecot/src/auth auth-worker-client.c, 1.11, 1.12 auth-worker-client.h, 1.1, 1.2 main.c, 1.44, 1.45

cras at dovecot.org cras at dovecot.org
Wed Jun 8 16:37:20 EEST 2005


Update of /var/lib/cvs/dovecot/src/auth
In directory talvi:/tmp/cvs-serv30924

Modified Files:
	auth-worker-client.c auth-worker-client.h main.c 
Log Message:
Auth workers were leaking memory for each request. Fixed also a few invalid
memory accesses at deinitialization.



Index: auth-worker-client.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/auth-worker-client.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- auth-worker-client.c	28 May 2005 12:51:43 -0000	1.11
+++ auth-worker-client.c	8 Jun 2005 13:37:17 -0000	1.12
@@ -29,8 +29,6 @@
 	struct timeout *to;
 };
 
-static void auth_worker_client_unref(struct auth_worker_client *client);
-
 static void
 auth_worker_client_check_throttle(struct auth_worker_client *client)
 {
@@ -101,9 +99,10 @@
 			str_append_str(str, request->extra_fields);
 	}
 	str_append_c(str, '\n');
-
 	o_stream_send(client->output, str_data(str), str_len(str));
-        auth_worker_client_check_throttle(client);
+
+	auth_request_unref(request);
+	auth_worker_client_check_throttle(client);
 	auth_worker_client_unref(client);
 }
 
@@ -134,6 +133,7 @@
 
 	if (auth_request->user == NULL || auth_request->service == NULL) {
 		i_error("BUG: PASSV had missing parameters");
+		auth_request_unref(auth_request);
 		return;
 	}
 
@@ -141,6 +141,7 @@
 		auth_request->passdb = auth_request->passdb->next;
 		if (auth_request->passdb == NULL) {
 			i_error("BUG: PASSV had invalid passdb num");
+			auth_request_unref(auth_request);
 			return;
 		}
 	}
@@ -169,9 +170,10 @@
 			str_append_str(str, request->extra_fields);
 	}
 	str_append_c(str, '\n');
-
 	o_stream_send(client->output, str_data(str), str_len(str));
-        auth_worker_client_check_throttle(client);
+
+	auth_request_unref(request);
+	auth_worker_client_check_throttle(client);
 	auth_worker_client_unref(client);
 }
 
@@ -204,6 +206,7 @@
 
 	if (auth_request->user == NULL || auth_request->service == NULL) {
 		i_error("BUG: PASSL had missing parameters");
+		auth_request_unref(auth_request);
 		return;
 	}
 
@@ -211,6 +214,7 @@
 		auth_request->passdb = auth_request->passdb->next;
 		if (auth_request->passdb == NULL) {
 			i_error("BUG: PASSL had invalid passdb num");
+			auth_request_unref(auth_request);
 			return;
 		}
 	}
@@ -233,7 +237,9 @@
 	str_append_c(str, '\n');
 
 	o_stream_send(client->output, str_data(str), str_len(str));
-        auth_worker_client_check_throttle(client);
+
+	auth_request_unref(auth_request);
+	auth_worker_client_check_throttle(client);
 	auth_worker_client_unref(client);
 }
 
@@ -253,6 +259,7 @@
 
 	if (auth_request->user == NULL || auth_request->service == NULL) {
 		i_error("BUG: USER had missing parameters");
+		auth_request_unref(auth_request);
 		return;
 	}
 
@@ -260,6 +267,7 @@
 		auth_request->userdb = auth_request->userdb->next;
 		if (auth_request->userdb == NULL) {
 			i_error("BUG: USER had invalid userdb num");
+			auth_request_unref(auth_request);
 			return;
 		}
 	}
@@ -397,14 +405,16 @@
 	client->fd = -1;
 
 	io_loop_stop(ioloop);
-        auth_worker_client_unref(client);
 }
 
-static void auth_worker_client_unref(struct auth_worker_client *client)
+void auth_worker_client_unref(struct auth_worker_client *client)
 {
 	if (--client->refcount > 0)
 		return;
 
+	if (client->fd != -1)
+		auth_worker_client_destroy(client);
+
 	i_stream_unref(client->input);
 	o_stream_unref(client->output);
 	i_free(client);

Index: auth-worker-client.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/auth-worker-client.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- auth-worker-client.h	2 Mar 2005 20:46:25 -0000	1.1
+++ auth-worker-client.h	8 Jun 2005 13:37:17 -0000	1.2
@@ -5,5 +5,6 @@
 
 struct auth_worker_client *auth_worker_client_create(struct auth *auth, int fd);
 void auth_worker_client_destroy(struct auth_worker_client *client);
+void auth_worker_client_unref(struct auth_worker_client *client);
 
 #endif

Index: main.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/auth/main.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- main.c	19 Apr 2005 13:11:12 -0000	1.44
+++ main.c	8 Jun 2005 13:37:17 -0000	1.45
@@ -250,16 +250,16 @@
 		i_warning("Killed with signal %d", lib_signal_kill);
 
 	if (worker_client != NULL)
-		auth_worker_client_destroy(worker_client);
+		auth_worker_client_unref(worker_client);
 	else
 		auth_request_handler_flush_failures();
 
+        auth_worker_server_deinit();
 	auth_master_listeners_deinit();
 	auth_request_handler_deinit();
 	auth_deinit(auth);
 	mech_deinit();
 
-        auth_worker_server_deinit();
         password_schemes_deinit();
 	random_deinit();
 



More information about the dovecot-cvs mailing list