diff --git a/include/proto/queue.h b/include/proto/queue.h index 77964feb3..7bf813707 100644 --- a/include/proto/queue.h +++ b/include/proto/queue.h @@ -1,23 +1,23 @@ /* - include/proto/queue.h - This file defines everything related to queues. - - Copyright (C) 2000-2008 Willy Tarreau - w@1wt.eu - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation, version 2.1 - exclusively. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ + * include/proto/queue.h + * This file defines everything related to queues. + * + * Copyright (C) 2000-2012 Willy Tarreau - w@1wt.eu + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, version 2.1 + * exclusively. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ #ifndef _PROTO_QUEUE_H #define _PROTO_QUEUE_H @@ -32,6 +32,8 @@ #include #include +#include + extern struct pool_head *pool2_pendconn; int init_pendconn(); @@ -68,7 +70,7 @@ static inline struct pendconn *pendconn_from_px(const struct proxy *px) { * for and if/else usage. */ static inline int may_dequeue_tasks(const struct server *s, const struct proxy *p) { - return (s && (s->nbpend || (p->nbpend && (s->state & SRV_RUNNING))) && + return (s && (s->nbpend || (p->nbpend && srv_is_usable(s->state, s->eweight))) && (!s->maxconn || s->cur_sess < srv_dynamic_maxconn(s))); } diff --git a/src/queue.c b/src/queue.c index 395d7522b..dd6e96218 100644 --- a/src/queue.c +++ b/src/queue.c @@ -109,7 +109,7 @@ struct session *pendconn_get_next_sess(struct server *srv, struct proxy *px) ps = pendconn_from_srv(srv); pp = pendconn_from_px(px); /* we want to get the definitive pendconn in */ - if (!pp || !(rsrv->state & SRV_RUNNING) || (rsrv->state & (SRV_GOINGDOWN|SRV_MAINTAIN))) { + if (!pp || !srv_is_usable(rsrv->state, rsrv->eweight)) { if (!ps) return NULL; } else {