Socket draining for sys_recvfile() (patch for 'reverse sendfile')

Jeremy Allison jra at samba.org
Fri Dec 30 21:17:22 MST 2011


On Fri, Dec 30, 2011 at 07:54:15PM -0800, Jeremy Allison wrote:
> 
> Got a fix. In order to make it work with the libsmb client libraries
> I need to remove some code in smbd/reply.c that deals with DOS error
> codes. I'm tracking down the history here..

Ok, got a more elegant fix. Turns out that mixing up the
drain_socket() functionality with the default_sys_recvfile()
functionality is an interface mistake, due to the different
requirements of the error return cases.

Well done Andrew for making me look at this closely :-). Nice
bit of legacy fixing there :-).

So I'm going to do 3 more patches.

1). Move drain_socket() functionality into a separate
function that copes with it's unique return case.

2). Remove the drain_socket() functionality from the
default_sys_recvfile() function which simplifies it
and considerably and allows it to correctly return
errors in the short write case.

3). Fix the pre-historic code in smbd/reply.c
that explicitly sets a DOS error code if a writeX
returns a short write - the modern libsmbclient
code simply doesn't cope with this (that's where
the NT_STATUS_INVALID_NETWORK_RESPONSE is coming
from - the detection code in libsmbclient). As
libsmbclient doesn't cope with this it's almost
certain a Windows server never does this (although
it'd be worthwhile testing this out).

Jeremy.


More information about the samba-technical mailing list