hello. I'm fairly new to libevent and especially evhttp, so I have a query 
whose solution may just be 'dont use evhttp that way'... the summary is: how 
can I know if an evhttp_request object is 'freed' behind my back, and avoid 
using it after it's dead?

I'm writing a simple single threaded libevent based http server that 
occasionally can't immediately respond to an incoming http request that has 
been passed into a generic handler callback. instead it just saves the 
evhttp_request pointer in my own list structure, and doesn't immediately call 
evhttp_send_reply or equivalent. instead it falls back to the main dispatch 
loop and lets other events happen.
some time later another event allows me to fill in a reply to the old request, 
and so I call evhttp_send_reply on the stored request pointer.
my issue is, that looking at the http.c code there are a few ways that the 
http_request I am storing a pointer to, could be freed. for example, if the 
incoming connection to a server goes away, it deletes all the outstanding 
requests. however my code won't get any notification that the connection or 
requests have gone away, so I will merrily (later on) make use of the request 
pointer after it's been freed.
what should I do? not use this pattern? use some callback mechanism I've 
missed? worry less? or patch evhttp_request_free() to call an optional callback?

any help or advice greatly appreciated. many thanks
Alex



Please consider the environment before printing this email :-)

This email and any files transmitted with it are confidential and intended 
solely for the use of the individual or entity to whom they are addressed.  If 
you have received this email in error please notify the sender immediately then 
delete this email.

Media Molecule Limited
Company Reg No 5665849
Registered in England.
_______________________________________________
Libevent-users mailing list
Libevent-users@monkey.org
http://monkeymail.org/mailman/listinfo/libevent-users

Reply via email to