appsession fix

From: Ryan Warnick <warnickr_1#isp01.net>
Date: Tue, 12 Feb 2008 14:21:52 -0700


We've been trying to use the latest release (1.3.14.2) of haproxy to do sticky sessions. Cookie insertion is not an option for us, although we would much rather use it, as we are trying to work around a problem where cookies are unreliable. The appsession functionality only partially worked
(it wouldn't read the session id out of a query string) until we made the
following code change to the get_srv_from_appsession function in proto_http.c:  

This code  

        if (appsession_hash_lookup(&(t->be->htbl_proxy),
asession_temp->sessid) == NULL) {       

 

was changed to  

        asession_temp = appsession_hash_lookup(&(t->be->htbl_proxy), asession_temp->sessid);

        if (asession_temp == NULL) {  

Also, we think it would be nice to allow for a little more flexibility in handling session ids in query strings. So, we would also like to propose the following code change also in the get_srv_from_appsession function in proto_http.c (changes in red):  

This code  

                if (t->be->appsession_name == NULL ||

                    (t->txn.meth != HTTP_METH_GET && t->txn.meth !=
HTTP_METH_POST) ||
                    (request_line = memchr(begin, ';', len)) == NULL ||

                    ((1 + t->be->appsession_name_len + 1 +
t->be->appsession_len) > (begin + len - request_line)))
                                return;

 

                /* skip ';' */

 

was changed to  

        if (t->be->appsession_name == NULL ||

            (t->txn.meth != HTTP_METH_GET && t->txn.meth != HTTP_METH_POST) ||

            (request_line = strstr(begin, t->be->appsession_name)) == NULL ||

            ((t->be->appsession_name_len + 1 + t->be->appsession_len) >
(begin + len - request_line)))

                return;

 

        /* skip ';'

        request_line++; */

 

It is likely that the strstr call will not be as fast as the memchr call, but we need this additional flexibility.  

Will you be able to make either of these changes part of the standard distribution?  

Thanks,

Ryan Received on 2008/02/12 22:21

This archive was generated by hypermail 2.2.0 : 2008/02/12 22:30 CET