changeset 20635:84c80c8b0e40

Close the pipes to the dnssrv child process. Fixes #3245
author Daniel Atallah <daniel.atallah@gmail.com>
date Tue, 25 Sep 2007 04:51:04 +0000
parents 275fe4d67158
children 4604cad304cb
files libpurple/dnssrv.c
diffstat 1 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/dnssrv.c	Mon Sep 24 08:17:19 2007 +0000
+++ b/libpurple/dnssrv.c	Tue Sep 25 04:51:04 2007 +0000
@@ -69,6 +69,7 @@
 	char *error_message;
 	GSList *results;
 #else
+	int fd_in, fd_out;
 	pid_t pid;
 #endif
 };
@@ -112,8 +113,11 @@
 	purple_restore_default_signal_handlers();
 #endif
 
-	if (read(in, query, 256) <= 0)
+	if (read(in, query, 256) <= 0) {
+		close(out);
+		close(in);
 		_exit(0);
+	}
 
 	size = res_query( query, C_IN, T_SRV, (u_char*)&answer, sizeof( answer));
 
@@ -179,6 +183,9 @@
 		ret = g_list_remove(ret, ret->data);
 	}
 
+	close(out);
+	close(in);
+
 	_exit(0);
 }
 
@@ -358,6 +365,8 @@
 	query_data->cb = cb;
 	query_data->extradata = extradata;
 	query_data->pid = pid;
+	query_data->fd_out = out[0];
+	query_data->fd_in = in[1];
 	query_data->handle = purple_input_add(out[0], PURPLE_INPUT_READ, resolved, query_data);
 
 	g_free(query);
@@ -399,6 +408,7 @@
 void
 purple_srv_cancel(PurpleSrvQueryData *query_data)
 {
+printf("purple_srv_cancel(%p)\n", query_data);
 	if (query_data->handle > 0)
 		purple_input_remove(query_data->handle);
 #ifdef _WIN32
@@ -414,6 +424,9 @@
 	}
 	g_free(query_data->query);
 	g_free(query_data->error_message);
+#else
+	close(query_data->fd_out);
+	close(query_data->fd_in);
 #endif
 	g_free(query_data);
 }