[Openais] evt message leak patch one more time.

Mark Haverkamp markh at osdl.org
Fri Jul 30 09:54:40 PDT 2004


I've replaced the while(1) and also found a problem in the destructor
where I was missing an indirection from the call to saQueueItemGet
causing the wrong address to be freed.  If this looks OK to you I'll
check it in.

Thanks,
Mark.


===== lib/evt.c 1.1 vs edited =====
--- 1.1/lib/evt.c	2004-07-29 11:41:40 -07:00
+++ edited/lib/evt.c	2004-07-30 09:47:10 -07:00
@@ -180,11 +180,28 @@
 static void evtHandleInstanceDestructor(void *instance)
 {
 	struct event_instance *evti = instance;
+	void **msg;
+	int empty;
+
+	/*
+	 * Empty out the queue if there are any pending messages
+	 */
+	while ((saQueueIsEmpty(&evti->ei_inq, &empty) == SA_OK) && !empty) {
+		saQueueItemGet(&evti->ei_inq, &msg);
+		saQueueItemRemove(&evti->ei_inq);
+		free(*msg);
+	}
 
+	/*
+	 * clean up the queue itself
+	 */
 	if (evti->ei_inq.items) {
 			free(evti->ei_inq.items);
 	}
 
+	/*
+	 * Disconnect from the server
+	 */
 	if (evti->ei_fd != -1) {
 		shutdown(evti->ei_fd, 0);
 		close(evti->ei_fd);
@@ -409,6 +426,7 @@
 			msg = *queue_msg;
 			memcpy(&dispatch_data, msg, msg->size);
 			saQueueItemRemove(&evti->ei_inq);
+			free(msg);
 		} else {
 			/*
 			 * Queue empty, read response from socket


-- 
Mark Haverkamp <markh at osdl.org>




More information about the Openais mailing list