On Tue, Dec 02, 2014 at 11:41:39PM +0100, Cyril Bonté wrote:
> Le 02/12/2014 22:48, Willy Tarreau a écrit :
> >On Tue, Dec 02, 2014 at 10:22:40PM +0100, Cyril Bonté wrote:
> >>Currently, HAPROXY_SERVER_CURCONN will never change from its initial
> >>value. That's embarrassing, maybe I'll have to change several parts of
> >>the previous patch in order to manage such variables.
> >
> >Don't worry, this branch is tagged development for a reason :-)
> >There's no reason to feel embarrassed by pushing things which
> >don't work, especially when several eyes watched it and didn't
> >notice anything!
> >
> >If you're not sure how to fix it, we can discuss it tomorrow if you want.
> 
> Well, I think I won't reinvent the wheel. I'll reproduce what is done 
> for check_statuses.
> 
> I'll create an enum to index the environment variables
> enum {
>       /* General use */
>       EXTCHECK_PATH = 0,
> 
>       /* Proxy specific environment variables */
>       EXTCHECK_HAPROXY_PROXY_NAME,
>       EXTCHECK_HAPROXY_PROXY_ID,
>       EXTCHECK_HAPROXY_PROXY_ADDR,
>       EXTCHECK_HAPROXY_PROXY_PORT,
> 
>       /* Server specific environment variables */
>       EXTCHECK_HAPROXY_SERVER_NAME,
>       EXTCHECK_HAPROXY_SERVER_ID,
>       EXTCHECK_HAPROXY_SERVER_ADDR,
>       EXTCHECK_HAPROXY_SERVER_PORT,
>       EXTCHECK_HAPROXY_SERVER_MAXCONN,
>       EXTCHECK_HAPROXY_SERVER_CURCONN,
>       EXTCHECK_SIZE
> };
> 
> a new type to store the environment variable name and the max length for 
> its value, with some specific values to indicate that the length will be 
> determined at init time, or will require enough space to store a long or 
> any other string representation.
> struct extcheck_env {
>       char *name;
>       int val_maxlen;
> };
> 
> This will allow to initialize all the environment variables, then update 
> some of them during each check call.

Semms to make sense.

> It will also allow me to remove the realloc I introduced. Only with 
> this, I already feel happier ;-)

I agree :-)

> I've already made some tests and it looks to work well for every cases I 
> can identify.

Perfect!

Thanks,
Willy


Reply via email to