[Openais] Re: evt message leak patch one more time.
Steven Dake
sdake at mvista.com
Fri Jul 30 10:28:17 PDT 2004
Looks good mark
I'll add similiar code for amf when I get back from vacation
Thanks!
-steve
On Fri, 2004-07-30 at 09:54, Mark Haverkamp wrote:
> 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
>
More information about the Openais
mailing list