Scheduler: on TRACE mode when closing connection, validate cs.

When trace mode is enabled through --trace, when the Scheduler will
close a connection, verify that no client_session associated exists
to the Scheduler entry, this condition may happen on bad API usage
by plugins.

Signed-off-by: Eduardo Silva <eduardo@monkey.io>
Epoll: move READ message after signal condition

Signed-off-by: Eduardo Silva <eduardo@monkey.io>
Core: new '-t' option to override TransportLayer from command line

Signed-off-by: Eduardo Silva <eduardo@monkey.io>
Merge branch 'master' of github.com:monkey/monkey
Core: adaptive network buffer size (Fix #163)

Monkey stack allows to a plugin to handle the network operations
in a low level layer, at that area the plugins Liana and PolarSSL
are the main ones in charge to add support for plain communication
and further SSL.

When working over plain sockets, the Networking plugin (liana) just
perform direct read from the system call to the clien_session buffer,
so it will read as of buffer capacity and then continue after each
event triggered by the Kernel. In the opposite side, when the plugin
requires some data processing after read(2) and before to return the
control to Monkey core, we may face a double-buffering and that is
the case of the PolarSSL plugin, where by obvious reasons it needs
it own buffer.

By RFC defition, SSL/TLS defines a maximum transaction of 2^14 bytes,
which is 16KB, so if we get an Event notification from the Kernel and the
plugin processed a number of bytes grater that the available on the caller
buffer (client_session), we may ended up with some un-read bytes in the
SSL layer.

This patch implements a few mechanisms to avoid the situation described:

1. The Plugin API at Networking level now implements a new callback
   called 'buffer_size', so from now all Networking plugins requires
   to implement it. Monkey core will call it with the purpose to ask if
   the plugin is implementing it own buffering and the size of it.

2. When initializing plugins and check the Networking plugin buffer size,
   If it returns something >= MK_REQUEST_CHUNK, the Configuration will be
   set to that value. Note that from that moment every request will require
   two memory allocations (a workaround for custom systems will in the next
   patch).

3. When invoking a Network read, now a plugin may be able to return a greater
   number of bytes requested by the caller. If this is faced, it means the
   Network plugin have some pending data to be read, so now the Request handler
   will consume that amount of data before to return to process other events.

note: as said a new patch will come to fix the need of double-memory allocation
      per request.

Signed-off-by: Eduardo Silva <eduardo@monkey.io>

Conflicts:
	src/mk_http.c
	src/mk_request.c
Request: initialize max_read

Signed-off-by: Eduardo Silva <eduardo@monkey.io>
PolarSSL: let io_read return more bytes than consumed

Signed-off-by: Eduardo Silva <eduardo@monkey.io>
PolarSSL: new get_bytes_avail() call

Signed-off-by: Eduardo Silva <eduardo@monkey.io>
Libmonkey: Fix clock_gettime undefined

Signed-off-by: kaspersky <gg.kaspersky@gmail.com>
Merge branch 'master' of https://github.com/monkey/monkey into ldpreload