[Openais] evt message leak patch
Mark Haverkamp
markh at osdl.org
Thu Jul 29 15:24:31 PDT 2004
Here is what I think will plug the message leak. Both in the destructor
and the dispatch function.
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-29 15:22:44 -07:00
@@ -180,11 +180,32 @@
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 (1) {
+ saQueueIsEmpty(&evti->ei_inq, &empty);
+ if (empty) {
+ break;
+ }
+ 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 +430,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