Previously, when a signation() or signal() call failed, we would free
the element we added to sh_old, but not actually clear the pointer.
This would leave a dangling pointer in sh_old that could cause a
crash later.
when sending chunked requests via multiple calls to evhttp_send_reply_chunk,
the client may close the connection before the server is done sending. this
used to cause a crash.
we introduce a new function evhttp_request_get_connection() that allows the
server to determine if the request is still associated with a connection.
If it's not, evhttp_request_free() needs to be called explicitly or the user
can call evhttp_send_reply_end() which just frees the request, too.
This patch fixes calls to the win32 api to explicitly call the char* versions
of the functions. This fixes build failures when libevent is built with the
UNICODE define.
Previously, we'd issue an HTTP/1.1 400 Bad Request" response on every
connection close, event if sever sent response already.
This patch changes the behavior, so we only issue the response on
close when the connection state is not DISCONNECTED, and so we set
the state to DISCONNECTED when the connection closes.
Includes a regression test; fixes sourceforge bug 2909909.
It turns out that kqueue_dealloc wasn't calling evsig_dealloc()
(because it doesn't use the main signal handler logic) so the sh_old
array was leaking.
This patch also introduces a fix in evsig_dealloc() where we set
the sh_old array to NULL when we free it, so that main/fork can pass.
William's original commit message:
Valgrind complains on startup because kq_init passes to kevent only
a partially initialized structure. The code doesn't expect kevent
to look at .fflags, .udata, or .data, I suppose, because it merely
tickles the kernel looking for an error response. But perhaps
that's unwarranted chuminess (notwithstanding that it's checking
for an OS X bug), and needless noise nonetheless.
This is necessary because it is not actually possible to use
evbuffer_readline() safely: it will treat "A\r\n" as 'A' EOL if it
reads it all at once, and as 'A' EOL EOL if there is a delay between
reading the \r and the \n.
Nicholas Marriott's comments on this patch:
Gilles is too busy so I've had a go at this, please see the diff
below. Rather than try to backport directly from 2.0 where the
evbuffer code is quite different, I've backported the _readln
function from when it was initially added in buffer.c r550. I can't
see any relevant bug fixes after this point so the function is
pretty much just copied in directly from that revision.
We were saying calloc(N,N*sizeof(struct event_list*)) when we should have
been saying calloc(N,sizeof(struct event_list*)). This wasted N*(N-1) words
of memory, where N was the number of priorities. This wouldn't be a big deal
for any sane number of priorities, but it's a bug nonetheless.
svn:r1526
On some systems (notably HPUX), there is already a
/usr/include/sys/_time.h, which our sys/_time.h shadows. Found and
diagnosed by Kathryn Hogg.
This is a quick fix for 1.4 only; for 2.0, I want to eliminate
compat/sys/_time.h entirely, and have util-internal subsume it.
svn:r1493
New backends like poll and kqueue and so on add fds to the queue in
the order that they are triggered. But the select backend currently
activates low-numbered fds first, whereas the poll and win32 backends
currently favor whatever fds have been on for the longest. This is no
good for fairness.
svn:r1327
Generally speaking, it way better to event_assign() an event when you
allocate it than to assign it before every time you event_add it: if
it is already event_add()ed, the assign will mess it up so that it
doesn't _look_ added, and event_add() will insert a second copy.
Later, event_del() will only delete the second copy. Eventually, the
event_base will have a dangling pointer to freed memory. Ouch!
svn:r1308