Clock: move sequential clock init to its own function

If the memory were allocated in a thread, it may happen too late.

Signed-off-by: Lauri Kasanen <cand@gmx.com>
Signed-off-by: Eduardo Silva <edsiper@gmail.com>
sched: Protect the wid init with a mutex

Signed-off-by: Lauri Kasanen <cand@gmx.com>
Signed-off-by: Eduardo Silva <edsiper@gmail.com>
memory: Correct the header to have the same definition as the source

Signed-off-by: Lauri Kasanen <cand@gmx.com>
Signed-off-by: Eduardo Silva <edsiper@gmail.com>
configure, headers: Make sure every header has include guards

Signed-off-by: Lauri Kasanen <cand@gmx.com>
Signed-off-by: Eduardo Silva <edsiper@gmail.com>
headers: Remove unused header file

Signed-off-by: Lauri Kasanen <cand@gmx.com>
Signed-off-by: Eduardo Silva <edsiper@gmail.com>
monkey: wait until all workers are ready

Otherwise the manager thread may cause a client to be added to an epoll fd
that has not been initialized yet.

Signed-off-by: Lauri Kasanen <cand@gmx.com>
Signed-off-by: Eduardo Silva <edsiper@gmail.com>
Monkey 1.0.0
Deprecate websockets and patas plugins

Signed-off-by: Eduardo Silva <edsiper@gmail.com>
Monkey v1.0.0

Signed-off-by: Eduardo Silva <edsiper@gmail.com>
Development of v1.1 begins

Signed-off-by: Eduardo Silva <edsiper@gmail.com>
Configure: find: user -xtype instead of -type

Signed-off-by: Eduardo Silva <edsiper@gmail.com>
utils: speed up mk_utils_utime2gmt non-cache path by 25%

Unsigned division is nicely faster than signed division.

Signed-off-by: Lauri Kasanen <cand@gmx.com>
Signed-off-by: Eduardo Silva <edsiper@gmail.com>
Scheduler: register new incoming sockets with MK_EPOLL_READ

Previous this patch, the Scheduler used to register each new incoming
socket with the MK_EPOLL_WRITE flag, so when the connection was established
epoll_wait(2) triggered the write event, meaning 'the socket is ready to
write'. On that moment the Connection handler realised that no Scheduler
information exists for that socket and run the mk_sched_register_client()
function, then invoke epoll_ctl(2) to change the socket mode to
MK_EPOLL_READ, so it start to wait for the incoming request string.

In HTTP the client always begins the communication sending the request, so
having a socket on MK_EPOLL_WRITE and then change it to MK_EPOLL_READ adds
a little overhead.

This patch makes the initial socket be registered with MK_EPOLL_READ and
make the Connection handler identify this new connection in the
mk_conn_read() function, avoiding the extra system call described in the
previous behavior.

Here is a little benchmark done with Valgrind/Callgrind:

  +------------------------+----------------+-----------------+--------+
  | function()             | before patch   |  after patch    |  gain  |
  +------------------------+------+---------+-----------------+--------+
  |                        | self | called  |  self | called  |        |
  +------------------------+------+---------+-------+---------+--------+
  | epoll_ctl(2)           | 0.15 |  15000  |  0.10 | 10000   |  44%   |
  +------------------------+------+---------+-------+---------+--------+
  | mk_epoll_change_mode() | 0.57 |  10000  |  0.27 |  5000   |  63%   |
  +------------------------+------+---------+-------+---------+--------+

Signed-off-by: Eduardo Silva <edsiper@gmail.com>
config: Move default workers to config_init

Signed-off-by: Lauri Kasanen <cand@gmx.com>
Signed-off-by: Eduardo Silva <edsiper@gmail.com>
Export the thread_key init for the lib

Signed-off-by: Lauri Kasanen <cand@gmx.com>
Signed-off-by: Eduardo Silva <edsiper@gmail.com>
sched: Return the worker thread id

Signed-off-by: Lauri Kasanen <cand@gmx.com>
Signed-off-by: Eduardo Silva <edsiper@gmail.com>
string: Add a function to turn a string to lowercase

Signed-off-by: Lauri Kasanen <cand@gmx.com>
Signed-off-by: Eduardo Silva <edsiper@gmail.com>
config: Make use of the tolower function

Signed-off-by: Lauri Kasanen <cand@gmx.com>
Signed-off-by: Eduardo Silva <edsiper@gmail.com>
request: Add a check for no index files

Signed-off-by: Lauri Kasanen <cand@gmx.com>
Signed-off-by: Eduardo Silva <edsiper@gmail.com>
plugin: Check that the would-be-removed handler matches

Signed-off-by: Lauri Kasanen <cand@gmx.com>
Signed-off-by: Eduardo Silva <edsiper@gmail.com>