This week I've finished implementing support for multiple sockets using
the Listen directive described in last week's entry.
Posix poll(2) function to monitor all listening sockets for incoming
clients and atomic functions is used to make sure the workers state is
the same as the master thread.

# Scheduler.

Synchronization is a requirement as the client protocol hooks is set
based on which listening socket the connection is received on, and all
connections are received in the main process thread.
To make some changes had to be done to the scheduler.

An `mk_list` can't be used safely across threads without looks I had
replace the current `mk_list` of `sched_connections` with an ordinary
c array.
The main benefit of using mk_list is that it's very simple to get an
unused sched_connection in constant time.
To counter the performance penalty from not being able to do this I keep
a `clock hand` pointed at last claimed entry and then check in front of
it for unused entries and behind for newly added entries.
In the worst case scenario, the full list will be traversed, but in most
cases it will not.
There are of course some bad corner cases, but there are many other
better things to optimize.

The timeout code has been rewritten so that an any timeout can be set on
a connection, and no traversal of the rb tree is done.
This should allow protocols to have their own timeout values while also
making the timeout-check a lot faster.

# Status

The branch I'm developing supports multiple protocols, uses a more
flexible plugin/handler api for requests and can have any number of
listening sockets.
From now until the end of gsoc I will concentrate on testing usage by
writing things that rely on these new changes and documentation.

One thing that will be very interesting is to implementing support for
HTTPS using the new protocol abstraction.

[Blog](https://lotrax.org/gsoc/gsoc-2013-status-future-protocols-week-10.html)
[Code](https://github.com/ksonny/monkey/tree/plugin_next)

-- 
Sonny Karlsson

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
Monkey mailing list
[email protected]
http://lists.monkey-project.com/listinfo/monkey

Reply via email to