Commit d4455ed4 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Correctly handle listen socket shutdown: Delete the poolsock instance,

pretend nothing else happened.
parent e749a3ee
...@@ -212,7 +212,6 @@ VCA_Accept(struct listen_sock *ls, struct wrk_accept *wa) ...@@ -212,7 +212,6 @@ VCA_Accept(struct listen_sock *ls, struct wrk_accept *wa)
int i; int i;
CHECK_OBJ_NOTNULL(ls, LISTEN_SOCK_MAGIC); CHECK_OBJ_NOTNULL(ls, LISTEN_SOCK_MAGIC);
assert(ls->sock >= 0);
vca_pace_check(); vca_pace_check();
while(!hack_ready) while(!hack_ready)
......
...@@ -137,7 +137,7 @@ static pthread_t thr_pool_herder; ...@@ -137,7 +137,7 @@ static pthread_t thr_pool_herder;
* for a brief moment and it takes up around 144 bytes. * for a brief moment and it takes up around 144 bytes.
*/ */
static void static int
pool_accept(struct pool *pp, struct worker *w, const struct poolsock *ps) pool_accept(struct pool *pp, struct worker *w, const struct poolsock *ps)
{ {
struct worker *w2; struct worker *w2;
...@@ -156,6 +156,11 @@ pool_accept(struct pool *pp, struct worker *w, const struct poolsock *ps) ...@@ -156,6 +156,11 @@ pool_accept(struct pool *pp, struct worker *w, const struct poolsock *ps)
memset(wa, 0, sizeof *wa); memset(wa, 0, sizeof *wa);
wa->magic = WRK_ACCEPT_MAGIC; wa->magic = WRK_ACCEPT_MAGIC;
if (ps->lsock->sock < 0) {
/* Socket Shutdown */
Lck_Lock(&pp->mtx);
return (-1);
}
if (VCA_Accept(ps->lsock, wa) < 0) { if (VCA_Accept(ps->lsock, wa) < 0) {
w->stats.sess_fail++; w->stats.sess_fail++;
/* We're going to pace in vca anyway... */ /* We're going to pace in vca anyway... */
...@@ -165,7 +170,7 @@ pool_accept(struct pool *pp, struct worker *w, const struct poolsock *ps) ...@@ -165,7 +170,7 @@ pool_accept(struct pool *pp, struct worker *w, const struct poolsock *ps)
Lck_Lock(&pp->mtx); Lck_Lock(&pp->mtx);
if (VTAILQ_EMPTY(&pp->idle)) if (VTAILQ_EMPTY(&pp->idle))
return; return (0);
w2 = VTAILQ_FIRST(&pp->idle); w2 = VTAILQ_FIRST(&pp->idle);
VTAILQ_REMOVE(&pp->idle, w2, list); VTAILQ_REMOVE(&pp->idle, w2, list);
Lck_Unlock(&pp->mtx); Lck_Unlock(&pp->mtx);
...@@ -184,7 +189,7 @@ void ...@@ -184,7 +189,7 @@ void
Pool_Work_Thread(void *priv, struct worker *w) Pool_Work_Thread(void *priv, struct worker *w)
{ {
struct pool *pp; struct pool *pp;
int stats_clean; int stats_clean, i;
struct poolsock *ps; struct poolsock *ps;
CAST_OBJ_NOTNULL(pp, priv, POOL_MAGIC); CAST_OBJ_NOTNULL(pp, priv, POOL_MAGIC);
...@@ -212,8 +217,13 @@ Pool_Work_Thread(void *priv, struct worker *w) ...@@ -212,8 +217,13 @@ Pool_Work_Thread(void *priv, struct worker *w)
/* Accept on a socket */ /* Accept on a socket */
ps = VTAILQ_FIRST(&pp->socks); ps = VTAILQ_FIRST(&pp->socks);
VTAILQ_REMOVE(&pp->socks, ps, list); VTAILQ_REMOVE(&pp->socks, ps, list);
pool_accept(pp, w, ps); i = pool_accept(pp, w, ps);
Lck_AssertHeld(&pp->mtx); Lck_AssertHeld(&pp->mtx);
if (i < 0) {
/* Socket Shutdown */
FREE_OBJ(ps);
continue;
}
VTAILQ_INSERT_TAIL(&pp->socks, ps, list); VTAILQ_INSERT_TAIL(&pp->socks, ps, list);
} else if (VTAILQ_EMPTY(&pp->socks)) { } else if (VTAILQ_EMPTY(&pp->socks)) {
/* Nothing to do: To sleep, perchance to dream ... */ /* Nothing to do: To sleep, perchance to dream ... */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment