hi list,
please find attached a patch to implement a simple mechanism,
via the new evhttp_is_cbset() function, to check is a given
http callback is already known to the libevent.

The patch applies to latest stable release libevent-1.4.9-stable.

Motivation
==========
Almost all is dynamic in our code, so the libevent-http callbacks
register/unregister procedures are made by plug-ins during
their startup/shutdown phases.

Due to a cut && paste error in a plug-in code I registered
the same http callback 2 times at plug-in startup and
unregistered it just once at plug-in shutdown.  Unfortunately
the libevent http register procedure does not check if the callback
has been already declared.  In the event of unbalanced register/unregister
callbacks the libevent still had a hook to a function that was really
out of available address space becuase the plug-in which defined
the callback was itself unloaded by the plug-in manager.

A http browser attempted to access to the plug-in embedded
web server while it was unloaded, and because the libevent
had registered the hook to the callback the program generated
a segmentation violation.

The attached simple program will attempt to show what happened
and how I tried to solve the problem (edit EVENTDIR in Makefile
to meet your libevent installation).

Another way to solve the problem is to allow the evhttp_set_cb()
function to check for already registered callbacks, but this
is out of the scope of the current patch.

tnks for your attention

/rocco

Attachment: webcallback.diff
Description: patch for unbalanced register/unregister http callbacks

Attachment: unbalanced-cb.tar.gz
Description: test program for the unbalanced cb patch

-- 
Rocco Carbone mail-to: <rocco /at/ ntop /dot/ org>
Pisa Italy

Life is in the details

In other words, you are welcome to use, share and improve me.
You are forbidden to forbid anyone else to use, share and
improve what I gave you.
_______________________________________________
Libevent-users mailing list
Libevent-users@monkey.org
http://monkeymail.org/mailman/listinfo/libevent-users

Reply via email to