[Sheepdog] [PATCH] fix a bug in rx() when read() returns 0 but connection is not marked as closed.
Liu Yuan
namei.unix at gmail.com
Wed Apr 25 08:05:27 CEST 2012
On 04/24/2012 03:59 PM, Li Wenpeng wrote:
> From: levin li <xingke.lwp at taobao.com>
>
> if read() returns 0,it means connection closed, but previous
> read() may set errno to EAGAIN, in which case rx() would just
> return 0 without set connection state as C_IO_CLOSED
>
> Signed-off-by: levin li <xingke.lwp at taobao.com>
> ---
> lib/net.c | 7 ++++++-
> 1 files changed, 6 insertions(+), 1 deletions(-)
>
> diff --git a/lib/net.c b/lib/net.c
> index 260ae38..8ac7c9e 100644
> --- a/lib/net.c
> +++ b/lib/net.c
> @@ -70,7 +70,12 @@ int rx(struct connection *conn, enum conn_state next_state)
> int ret;
>
> ret = read(conn->fd, conn->rx_buf, conn->rx_length);
> - if (!ret || ret < 0) {
> + if (!ret) {
> + conn->c_rx_state = C_IO_CLOSED;
> + return 0;
> + }
> +
> + if (ret < 0) {
> if (errno != EAGAIN)
> conn->c_rx_state = C_IO_CLOSED;
> return 0;
Applied.
Thanks,
Yuan
More information about the sheepdog
mailing list