]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[PATCH] appsessions: cleanup DEBUG_HASH and initialize request_counter
authorAleksandar Lazic <al-haproxy@none.at>
Wed, 13 Aug 2008 17:57:02 +0000 (19:57 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 13 Aug 2008 21:43:26 +0000 (23:43 +0200)
This patch cleanup the -DDEBUG=DEBUG_HASH output setting and initialize
the request_counter for the appsessions.

src/proto_http.c
src/sessionhash.c

index 59d0479c82ec853dfb3ea38ec87ad1fc8b07a2c6..8a8bfffcab0d2fee50e948d4d575c67609c467f5 100644 (file)
@@ -4412,7 +4412,7 @@ void manage_client_side_cookies(struct session *t, struct buffer *req)
                                if ((t->be->appsession_name != NULL) &&
                                    (memcmp(p1, t->be->appsession_name, p2 - p1) == 0)) {
                                        /* first, let's see if the cookie is our appcookie*/
-                           
+
                                        /* Cool... it's the right one */
 
                                        asession_temp = &local_asession;
@@ -4440,12 +4440,14 @@ void manage_client_side_cookies(struct session *t, struct buffer *req)
 
                                                asession_temp->sessid = local_asession.sessid;
                                                asession_temp->serverid = local_asession.serverid;
+                                               asession_temp->request_count = 0;
                                                appsession_hash_insert(&(t->be->htbl_proxy), asession_temp);
                                        } else {
                                                /* free previously allocated memory */
                                                pool_free2(apools.sessid, local_asession.sessid);
                                        }
                                        if (asession_temp->serverid == NULL) {
+                                               /* TODO redispatch request */
                                                Alert("Found Application Session without matching server.\n");
                                        } else {
                                                struct server *srv = t->be->srv;
@@ -4468,6 +4470,11 @@ void manage_client_side_cookies(struct session *t, struct buffer *req)
                                        }/* end else if server == NULL */
 
                                        asession_temp->expire = tick_add_ifset(now_ms, t->be->timeout.appsession);
+                                       asession_temp->request_count++;
+#if defined(DEBUG_HASH)
+                                       Alert("manage_client_side_cookies\n");
+                                       appsession_hash_dump(&(t->be->htbl_proxy));
+#endif
                                }/* end if ((t->proxy->appsession_name != NULL) ... */
                        }
 
@@ -4904,6 +4911,7 @@ void manage_server_side_cookies(struct session *t, struct buffer *rtr)
                                        }
                                        asession_temp->sessid = local_asession.sessid;
                                        asession_temp->serverid = local_asession.serverid;
+                                       asession_temp->request_count = 0;
                                        appsession_hash_insert(&(t->be->htbl_proxy), asession_temp);
                                } else {
                                        /* free wasted memory */
@@ -4923,8 +4931,9 @@ void manage_server_side_cookies(struct session *t, struct buffer *rtr)
                                        memcpy(asession_temp->serverid, t->srv->id, server_id_len);
                      
                                asession_temp->expire = tick_add_ifset(now_ms, t->be->timeout.appsession);
-
+                               asession_temp->request_count++;
 #if defined(DEBUG_HASH)
+                               Alert("manage_server_side_cookies\n");
                                appsession_hash_dump(&(t->be->htbl_proxy));
 #endif
                        }/* end if ((t->proxy->appsession_name != NULL) ... */
@@ -5078,6 +5087,7 @@ void get_srv_from_appsession(struct session *t, const char *begin, int len)
                }
                asession_temp->sessid = local_asession.sessid;
                asession_temp->serverid = local_asession.serverid;
+               asession_temp->request_count=0;
                appsession_hash_insert(&(t->be->htbl_proxy), asession_temp);
        }
        else {
@@ -5089,9 +5099,11 @@ void get_srv_from_appsession(struct session *t, const char *begin, int len)
        asession_temp->request_count++;
 
 #if defined(DEBUG_HASH)
+       Alert("get_srv_from_appsession\n");
        appsession_hash_dump(&(t->be->htbl_proxy));
 #endif
        if (asession_temp->serverid == NULL) {
+               /* TODO redispatch request */
                Alert("Found Application Session without matching server.\n");
        } else {
                struct server *srv = t->be->srv;
index eb5c213d437acd5eb273f85ef72b0aa3633091bc..80683900a1085e6f8e0d84555495576fd77ed423 100644 (file)
@@ -15,7 +15,7 @@
 
 #include <common/sessionhash.h>
 #include <string.h>
-#ifdef TEST
+#ifdef DEBUG_HASH
 #include <stdio.h>
 #endif
 
@@ -112,14 +112,14 @@ void appsession_hash_destroy(struct appsession_hash *hash)
 void appsession_hash_dump(struct appsession_hash *hash)
 {
        unsigned int idx;
-       appsess *sess_head, *item;
+       appsess *item;
 
-       printf("Dumping hashtable 0x%x\n", hash);
+       printf("Dumping hashtable 0x%p\n", hash);
        for (idx = 0; idx < TABLESIZE; idx++) {
                /* we don't even need to call _safe because we return at once */
                list_for_each_entry(item, &hash->table[idx], hash_list) {
-                       printf("\ttable[%d]:\t%s\t-> 0x%x\n", idx, item->sessid,
-                                       item);
+                       printf("\ttable[%d]:\t%s\t-> %s request_count %lu\n", idx, item->sessid,
+                                       item->serverid, item->request_count);
                }
        }
        printf(".\n");