Move all statistics gathering to poll_waitevents().

The handler callback should now return a bitmask with bits set
according to what it did when it was called. That way the actual
statistics gathering can be done in poll_waitevents() and the
handler need not be aware of any thread structs.

Actually, the only thing that needs any assistance is accept handling,
because in poll_waitevents() we do not know whether a READ event
relates to a listening or a normal socket, that is, should the
event be counted as an accept or as a read.
This commit is contained in:
Johan Wikman
2017-02-15 09:21:15 +02:00
parent dec2bcdab2
commit b11b848e66
2 changed files with 59 additions and 15 deletions

View File

@ -18,6 +18,16 @@
#include <maxscale/cdefs.h>
typedef enum mxs_poll_action
{
MXS_POLL_NOP = 0x00,
MXS_POLL_ACCEPT = 0x01,
MXS_POLL_READ = 0x02,
MXS_POLL_WRITE = 0x04,
MXS_POLL_HUP = 0x08,
MXS_POLL_ERROR = 0x10,
} mxs_poll_action_t;
typedef struct mxs_poll_data
{
/** Pointer to function that knows how to handle events for this particular
@ -26,8 +36,10 @@ typedef struct mxs_poll_data
* @param data The `mxs_poll_data` instance that contained this pointer.
* @param wid The worker thread id.
* @param events The epoll events.
*
* @return A combination of mxs_poll_action_t enumeration values.
*/
void (*handler)(struct mxs_poll_data *data, int wid, uint32_t events);
uint32_t (*handler)(struct mxs_poll_data *data, int wid, uint32_t events);
struct
{