]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MINOR] add back-references to sessions for later use by a dumper.
authorWilly Tarreau <w@1wt.eu>
Sun, 7 Dec 2008 19:16:23 +0000 (20:16 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 7 Dec 2008 20:57:02 +0000 (21:57 +0100)
This is the first step in implementing a session dump tool.
A session dump will need restart points. It will be necessary for
it to get references to sessions which can be moved when the session
dies.

The principle is not that complex : when a session ends, it looks for
any potential back-references. If it finds any, then it moves them to
the next session in the list. The dump function will of course have
to restart from that new point.

include/types/session.h
src/client.c
src/proto_uxst.c
src/session.c

index eaa053fbfbac858df2c31d3566295b60d6718d68..7630bc30c18e3eafc6ad36d2ca8883630a576e92 100644 (file)
@@ -153,6 +153,7 @@ enum {
  */
 struct session {
        struct list list;                       /* position in global sessions list */
+       struct list back_refs;                  /* list of users tracking this session */
        struct task *task;                      /* the task associated with this session */
        /* application specific below */
        struct listener *listener;              /* the listener by which the request arrived */
index a9625dac110b00c3e1208fdea13a2b91a512646e..4e8004e7666b887e36a8f964e9d51b7b5ccc197f 100644 (file)
@@ -66,6 +66,7 @@ int event_accept(int fd) {
        struct session *s;
        struct http_txn *txn;
        struct task *t;
+       struct bref *bref, *back;
        int cfd;
        int max_accept = global.tune.maxaccept;
 
@@ -108,6 +109,7 @@ int event_accept(int fd) {
                }
 
                LIST_ADDQ(&sessions, &s->list);
+               LIST_INIT(&s->back_refs);
 
                s->flags = 0;
                s->term_trace = 0;
@@ -464,6 +466,11 @@ int event_accept(int fd) {
  out_free_task:
        pool_free2(pool2_task, t);
  out_free_session:
+       list_for_each_entry_safe(bref, back, &s->back_refs, users) {
+               LIST_DEL(&bref->users);
+               LIST_ADDQ(&LIST_ELEM(s->list.n, struct session *, list)->back_refs, &bref->users);
+               bref->ref = s->list.n;
+       }
        LIST_DEL(&s->list);
        pool_free2(pool2_session, s);
  out_close:
index 06ec185704ec6fd044589223bdfa6587f3bf0be7..25432687a2c2826772b4c6746e7079f20812a893 100644 (file)
@@ -360,6 +360,7 @@ int uxst_event_accept(int fd) {
        struct listener *l = fdtab[fd].owner;
        struct session *s;
        struct task *t;
+       struct bref *bref, *back;
        int cfd;
        int max_accept;
 
@@ -409,6 +410,7 @@ int uxst_event_accept(int fd) {
                }
 
                LIST_ADDQ(&sessions, &s->list);
+               LIST_INIT(&s->back_refs);
 
                s->flags = 0;
                s->term_trace = 0;
@@ -545,6 +547,11 @@ int uxst_event_accept(int fd) {
  out_free_task:
        pool_free2(pool2_task, t);
  out_free_session:
+       list_for_each_entry_safe(bref, back, &s->back_refs, users) {
+               LIST_DEL(&bref->users);
+               LIST_ADDQ(&LIST_ELEM(s->list.n, struct session *, list)->back_refs, &bref->users);
+               bref->ref = s->list.n;
+       }
        LIST_DEL(&s->list);
        pool_free2(pool2_session, s);
  out_close:
index a6190730d081701172688a15ebbba79f4df6c5b2..e82bfccdf1dbd570123222d0274b634ad997fea9 100644 (file)
@@ -42,6 +42,7 @@ void session_free(struct session *s)
 {
        struct http_txn *txn = &s->txn;
        struct proxy *fe = s->fe;
+       struct bref *bref, *back;
 
        if (s->pend_pos)
                pendconn_free(s->pend_pos);
@@ -82,6 +83,12 @@ void session_free(struct session *s)
        pool_free2(pool2_requri, txn->uri);
        pool_free2(pool2_capture, txn->cli_cookie);
        pool_free2(pool2_capture, txn->srv_cookie);
+
+       list_for_each_entry_safe(bref, back, &s->back_refs, users) {
+               LIST_DEL(&bref->users);
+               LIST_ADDQ(&LIST_ELEM(s->list.n, struct session *, list)->back_refs, &bref->users);
+               bref->ref = s->list.n;
+       }
        LIST_DEL(&s->list);
        pool_free2(pool2_session, s);