Seeing 'Short read' error in Samba-plugin's pwrite() while reading data from socket data.

Jeremy Allison jra at samba.org
Mon May 12 13:36:46 MDT 2014


On Mon, May 12, 2014 at 11:56:59PM +0530, sandeep nag wrote:
> I am seeing 'Short read' errors in pwrite() call of our Samba-VFS plugin
> while reading data from socket data. Please suggest me the function to
> debug in samba code and tell me, what could be the possible reasons for
> 'Short read' errors and how can it be fixed.
> 
> 
>  bytes_read = 0;
>     while(bytes_read != n)
>     {
>         read_ret = read(wd->u.rfd, buf + bytes_read, n - bytes_read);
>         if (read_ret == 0)
>         {
>             read_ret = -1;
>             CIFS_NOTICE("%s: Short read from socket, n %ld, bytes_read
> %ld,"    <==== This error is seen in  logs.
>                         " errno %d", __FUNCTION__, n, bytes_read, errno);
>             if (errno == 0)
>             {
>                 errno = EIO;
>             }
>         }
> 
>         if (read_ret == -1)
>         {
>             if (errno == EINTR)
>                 continue;
> 
>             assert(errno);
>             err = ERRNO_TO_CIFS_ERROR(errno);
>             CIFS_ERROR_DONE(err, "%s: Error reading file data from socket",
>                                 __FUNCTION__);
>         }
> 
>         bytes_read += read_ret;

The main smbd socket is non-blocking.

What this means is that it can return less
than was asked for, and your code needs to
be able to cope with this.

If you do a read on a non-blocking socket
and there's nothing to read you should
get -1,EAGAIN or EWOULDBLOCK.

However, receiving a zero return usually
means the other end (the client) has
shut down the socket. Can you get a
wireshark trace when this is occurring,
so you can see if this is indeed the
case at the TCP layer ?

Jeremy.


More information about the samba-technical mailing list