Commits
- Commit:
4842c72d9f3f45478cb641e15a3272e541fb8a18
- From:
- Omar Polo <op@omarpolo.com>
- Date:
fmt
- Commit:
80444938654389aa7970aaa43c4590d63da6844d
- From:
- Omar Polo <op@omarpolo.com>
- Date:
move bufferevent initialization early in handle_handshake
the error path needs an initialized bufferevent too, otherwise it'll
crash when trying to write the response.
This moves the initialisation early, right after the tls_handshake.
Another option would be to initialise it in do_accept, but that may be
too early.
- Commit:
c62a411f4f5c0a9b9ef6a1a474ee976bf5f711af
- From:
- Omar Polo <op@omarpolo.com>
- Date:
don't die on ECONNABORTED
ECONNABORTED is returned if a connections gets aborted after being
queued before the accept(2). I had some cases of
accept: Software caused connection abort
on FreeBSD, this should avoid that.
- Commit:
5eb3fc905f5e3bd2f2d586fb1e0ceda879500b3e
- From:
- Omar Polo <op@omarpolo.com>
- Date:
don't work around a missing -Wno-unused-parameter
It's been there for a long time, and it's frankly annoying to pretend
to use parameters. Most of the time, they're there to satisfy an
interface and nothings more.
- Commit:
207b3e80d867693ff74cf99c84f7dd41386adba1
- From:
- Omar Polo <op@omarpolo.com>
- Date:
Store clients inside a splay tree
From day one we've been using a static array of client struct to hold
the clients data. This has variuos drawbacks, among which:
* reuse of the storage ("shades of heartbleed")
* maximum fixed amount of clients connected at the same time
* bugs are harder to debug
The last point in particular is important because if we mess the client
ids, or try to execute some functions (e.g. the various fcgi_*) after a
client has been disconnected, it's harder to "see" this "use after
free"-tier kind of bug.
Now I'm using a splay tree to hold the data about the live connections.
Each client' data is managed by malloc. If we try to access a client
data after the disconnection we'll probably crash with a SIGSEGV and
find the bug is more easy.
Performance-wise the connection phase should be faster since we don't
have to loop anymore to find an empty spot in the clients array, but
some operations could be slightly slower (compare the O(1) access in an
array with a SPLAY_FIND operation -- still be faster than O(n) thought.)
- Commit:
4cd25209651f224be8c34d6006ef689963ce37d5
- From:
- Omar Polo <op@omarpolo.com>
- Date:
one FastCGI connection per client
FastCGI is designed to multiplex requests over a single connection, so
ideally the server can open only one connection per worker to the
FastCGI application and that's that.
Doing this kind of multiplexing makes the code harder to follow and
easier to break/leak etc on the gmid side however. OpenBSD' httpd
seems to open one connection per client, so why can't we too?
One connection per request is still way better (lighter) than using
CGI, and we can avoid all the pitfalls of the multiplexing (keeping
track of "live ids", properly shut down etc...)
- Commit:
e4daebe44aedd66413f82319252a7e579133945d
- From:
- Omar Polo <op@omarpolo.com>
- Date:
plug a memory leak
c->req is set in client_read but never deallocated
- Commit:
807a80cb9efdf631c3717fdca884bd0119493d45
- From:
- Omar Polo <op@omarpolo.com>
- Date:
fmt
- Commit:
acafce5b7ddd4342e45a7731ae3f261e6f202a77
- From:
- Omar Polo <op@omarpolo.com>
- Date:
libevent2 fix: unfreeze the client evbuffer
libevent2 has this concept of "freezeness" of a buffer. It's a way to
avoid accidentally write/remove data from the wrong "edge" of the
buffer. The client_tls_{read,write} functions need to add/drain data
from the opposite edge, hence the need for the unfreeze call.
This is the minimum change in order to work on libevent2 too. Another
way would be to define evbuffer_{un,}freeze as NOP on libevent 1, but
it's ugly IMHO.
- Commit:
efe7d180292726775fb3ae5e6af593490a264c60
- From:
- Omar Polo <op@omarpolo.com>
- Date:
new I/O handling on top of bufferevents
This is a big change in how gmid handles I/O. Initially we used a
hand-written loop over poll(2), that then was evolved into something
powered by libevent basic API. This meant that there were a lot of
small "asynchronous" function that did one step, eventually scheduling
the re-execution, that called each others in a chain.
The new implementation revolves completely around libevent'
bufferevents. It's more clear, as everything is implemented around the
client_read and client_write functions.
There is still space for improvements, like adding timeouts for one, but
it's solid enough to be committed as is and then further improved.
- Commit:
741b69be96397e0ec6db0c84b4ead4f41363ea98
- From:
- Omar Polo <op@omarpolo.com>
- Date:
fastcgi completely asynchronous
This changes the fastcgi implementation from a blocking I/O to an
async implementation on top of libevent' bufferevents.
Should improve the responsiveness of gmid especially when using remote
fastcgi applications.
- Commit:
83fe545a2b8c892e70ecf6b48180c27e6bc6b414
- From:
- Omar Polo <op@omarpolo.com>
- Date:
initialize mbufhead
- Commit:
3571854e942b2354ae216f340add076d71d0776a
- From:
- Omar Polo <op@omarpolo.com>
- Date:
fix possible out-of-bound access
While computing the parent directory it an out-of-bound access can
occur, which usually means the server process dies.
In particular, it can be triggered by making a request for a
non-existent file in the root of a virtual host if the path matches
the `cgi` pattern.
Thanks cage for helping in debugging!
- Commit:
353e3c8ebe516943a38d051a0bf390bb6116574c
- From:
- Omar Polo <op@omarpolo.com>
- Date:
style
- Commit:
a91ad7f2ffac3f1cec0c6c42e780ab5efc92ba5c
- From:
- Omar Polo <op@omarpolo.com>
- Date:
drop unnecessary bzero
the whole struct client is already memset'd to 0 in do_accept.
handle_handshake doesn't touch the request or iri buffer in the code
path that leads to handle_open_conn. (It does so in the error router
alone.)