]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: register peer sync handler in the proper order
authorWilly Tarreau <w@1wt.eu>
Thu, 31 May 2012 12:16:59 +0000 (14:16 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 31 May 2012 12:16:59 +0000 (14:16 +0200)
HervĂ© Commowick reported a failure to resync upon restart caused by a
segfault on the old process. This is due to the data_ctx of the connection
being initialized after the stream interface.

src/peers.c
src/stream_interface.c

index 0ab2e5221a30d4799cb99c0b160576e246c6d30d..a4ea915e52ffb32220432529ffa5d573ab64ad75 100644 (file)
@@ -1162,10 +1162,10 @@ static struct session *peer_session_create(struct peer *peer, struct peer_sessio
        s->si[0].flags = SI_FL_NONE;
        if (s->fe->options2 & PR_O2_INDEPSTR)
                s->si[0].flags |= SI_FL_INDEP_STR;
-       s->si[0].conn.data_ctx = (void *)ps;
-       s->si[0].applet.st0 = PEER_SESSION_CONNECT;
 
        stream_int_register_handler(&s->si[0], &peer_applet);
+       s->si[0].applet.st0 = PEER_SESSION_CONNECT;
+       s->si[0].conn.data_ctx = (void *)ps;
 
        s->si[1].conn.t.sock.fd = -1; /* just to help with debugging */
        s->si[1].owner = t;
index ceed602743492fd2db2c54fb5133524710c22756..5f7ac3dc6e2e56372540b5cf6626c8af0719c54e 100644 (file)
@@ -336,7 +336,8 @@ static void stream_int_chk_snd(struct stream_interface *si)
  * it is solicited. The task's processing function must call the applet's
  * function before returning. It must be deleted by the task handler using
  * stream_int_unregister_handler(), possibly from within the function itself.
- * It also pre-initializes applet.state to zero.
+ * It also pre-initializes applet.state to zero and the connection context
+ * to NULL.
  */
 struct task *stream_int_register_handler(struct stream_interface *si, struct si_applet *app)
 {