BUG/MEDIUM: peers: recent applet changes broke peers updates scheduling

Since appctx are scheduled out of streams, it's pointless to wake up
the task managing the stream to push updates, they won't be seen. In
fact unit tests work because silent sessions are restarted after 5s of
idle and the exchange is correctly scheduled during startup!

So we need to notify the appctx instead. For this we add a pointer to
the appctx in the peer session.

No backport is needed of course.
This commit is contained in:
Willy Tarreau 2015-04-27 18:40:14 +02:00
parent 6e2979ca31
commit e5843b383d
2 changed files with 10 additions and 4 deletions

View File

@ -39,6 +39,7 @@ struct peer_session {
struct shared_table *table; /* shared table */ struct shared_table *table; /* shared table */
struct peer *peer; /* current peer */ struct peer *peer; /* current peer */
struct stream *stream; /* current transport stream */ struct stream *stream; /* current transport stream */
struct appctx *appctx; /* the appctx running it */
unsigned int flags; /* peer session flags */ unsigned int flags; /* peer session flags */
unsigned int statuscode; /* current/last session status code */ unsigned int statuscode; /* current/last session status code */
unsigned int update; /* current peer acked update */ unsigned int update; /* current peer acked update */

View File

@ -193,6 +193,7 @@ static void peer_session_release(struct appctx *appctx)
if (ps) { if (ps) {
if (ps->stream == s) { if (ps->stream == s) {
ps->stream = NULL; ps->stream = NULL;
ps->appctx = NULL;
if (ps->flags & PEER_F_LEARN_ASSIGN) { if (ps->flags & PEER_F_LEARN_ASSIGN) {
/* unassign current peer for learning */ /* unassign current peer for learning */
ps->flags &= ~(PEER_F_LEARN_ASSIGN); ps->flags &= ~(PEER_F_LEARN_ASSIGN);
@ -421,6 +422,7 @@ switchstate:
peer_session_forceshutdown(ps->stream); peer_session_forceshutdown(ps->stream);
} }
ps->stream = s; ps->stream = s;
ps->appctx = appctx;
break; break;
} }
} }
@ -1173,6 +1175,8 @@ static struct stream *peer_session_create(struct peer *peer, struct peer_session
actconn++; actconn++;
totalconn++; totalconn++;
ps->appctx = appctx;
ps->stream = s;
return s; return s;
/* Error unrolling */ /* Error unrolling */
@ -1260,11 +1264,11 @@ static struct task *process_peer_sync(struct task * task)
st->flags |= SHTABLE_F_RESYNC_ASSIGN; st->flags |= SHTABLE_F_RESYNC_ASSIGN;
/* awake peer stream task to handle a request of resync */ /* awake peer stream task to handle a request of resync */
task_wakeup(ps->stream->task, TASK_WOKEN_MSG); appctx_wakeup(ps->appctx);
} }
else if ((int)(ps->pushed - ps->table->table->localupdate) < 0) { else if ((int)(ps->pushed - ps->table->table->localupdate) < 0) {
/* awake peer stream task to push local updates */ /* awake peer stream task to push local updates */
task_wakeup(ps->stream->task, TASK_WOKEN_MSG); appctx_wakeup(ps->appctx);
} }
/* else do nothing */ /* else do nothing */
} /* SUCCESSCODE */ } /* SUCCESSCODE */
@ -1305,6 +1309,7 @@ static struct task *process_peer_sync(struct task * task)
if (ps->stream) { if (ps->stream) {
peer_session_forceshutdown(ps->stream); peer_session_forceshutdown(ps->stream);
ps->stream = NULL; ps->stream = NULL;
ps->appctx = NULL;
} }
} }
} }
@ -1330,7 +1335,7 @@ static struct task *process_peer_sync(struct task * task)
* or during previous connect, peer replies a try again statuscode */ * or during previous connect, peer replies a try again statuscode */
/* connect to the peer */ /* connect to the peer */
ps->stream = peer_session_create(ps->peer, ps); peer_session_create(ps->peer, ps);
} }
else { else {
/* Other error cases */ /* Other error cases */
@ -1346,7 +1351,7 @@ static struct task *process_peer_sync(struct task * task)
(int)(ps->pushed - ps->table->table->localupdate) < 0) { (int)(ps->pushed - ps->table->table->localupdate) < 0) {
/* current stream active and established /* current stream active and established
awake stream to push remaining local updates */ awake stream to push remaining local updates */
task_wakeup(ps->stream->task, TASK_WOKEN_MSG); appctx_wakeup(ps->appctx);
} }
} /* stopping */ } /* stopping */
/* Wakeup for re-connect */ /* Wakeup for re-connect */