try_read_network doubt

dormando dormando at rydia.net
Fri Feb 22 04:38:50 UTC 2008


Hey,

So I think this is actually okay, but I've applied the patch (sans the
print) since we probably should be closing the socket on any unhandled
error.

What *should* happen now though:

Either the socket is EINTR, or maybe EBADF or something. EINTR is okay,
we return zero, and the socket is immediately readable again.
Or it returns some real unknown error and the socket is then closed.

When comes around again, but returns 0, then we close it on our side.

So technically it *should* be okay, but explicitly closing it should
help guarantee we don't get in a wedged state.

If someone knows better, please speak up though :)

-Dormando

Tao Hui wrote:
> Hi!
>     I have a doubt, in memcached-1.2.4 try_read_network(conn *c)
> funcation, when read returns -1 and  errno  is not  EWOULDBLOCK or
> EAGAIN, it returns 0. If it's more suitable to change state to
> conn_closing and return 1. the patch is as below:
> 1928,1934c1928
> <             else {
> <                               /* otherwise we have a real error, on
> which we close the connection */
> <                               if (settings.verbose > 0)
> <                             
>           fprintf(stderr, "Failed to read, and not due to blocking\n");
> <                               conn_set_state(c, conn_closing);
> <                               return 1;
> <                       }
> ---
>>             else return 0;



More information about the memcached mailing list