Re: add new event handler

From: Willy Tarreau <w#1wt.eu>
Date: Wed, 11 Jun 2008 08:00:07 +0200


Hi Aleks,

On Tue, Jun 10, 2008 at 11:25:34PM +0200, Aleksandar Lazic wrote:
> Hi Willy,
>
> when I want to add a new event handler what are the steps.
>
> I figured out the following:
>
> 1.) if necessary a include/common/HANDLER.h
> 2.) add ev_HANDLER.c in src and the content ;-)
>
> 3.) add in src/cfgparse.c the noHANDLER option
>
> .
> .
> else if (!strcmp(args[0], "noHANDLER")) {
> cfg_polling_mechanism &= ~POLL_USE_HANDLER;
> }
> .
> .
>
> 4.) add in src/haproxy.c
>
> usage(){
> .
> .
> #if defined(ENABLE_HANDLER)
> " -dHAND disables HANDLER() usage even when
> available\n"
> #endif
> .
> .
> }
>
> init(){
> .
> .
> if (!(cfg_polling_mechanism & POLL_USE_HANDLER))
> disable_poller("HANDLER");
> .
> .
>
> 5.) add in Makefile USE_HANDLER and OPTIONS_OBJS += src/ev_HANDLER.o
>
> anything else?

nothing I can think of. Do not forget to copy the constructor function from another handler, it is the one which registers it.

> As I have understand right the 'pref' in 'struct poller' defines the
> default handler on the platform right?

that's right. I have arbitrarily assigned the following values :

  select = 150
  poll = 200
  epoll = 300
  kqueue = 300
  sepoll = 400

The highest supported on your platform wins. The idea is to classify them by performance order. If you have an O(1) event handler (say, /dev/poll on Solaris), you might want to set it to 300. That way we have all platform specific optimizations at 300, and their optimized derivatives (speculative ones) can be set to 400.

Cheers,
Willy Received on 2008/06/11 08:00

This archive was generated by hypermail 2.2.0 : 2008/06/11 08:15 CEST