[PATCH] Fix bug 9412 - SMB2 server doesn't support recvfile.
jones.kstw at gmail.com
Tue Apr 8 19:46:12 MDT 2014
2014-04-07 21:12 GMT+08:00 Stefan (metze) Metzmacher <metze at samba.org>:
> I think you got that wrong, the man page says:
> Under Linux, select() may report a socket file descriptor as
> "ready for reading", while nevertheless a subse-
> quent read blocks. This could for example happen when data has
> arrived but upon examination has wrong checksum
> and is discarded. There may be other circumstances in which a
> file descriptor is spuriously reported as ready.
> Thus it may be safer to use O_NONBLOCK on sockets that should not
> That means you if you 100% don't want to be blocked you should use
> O_NONBLOCK in combination with select()/poll().
Great! Thanks to point this,
or i am afraid my poor understanding would mislead the wrong direction.
+ /* FIXME: For rare cases:
> + * case1) a high latency network.
> + * case2) a network undergoing severe
> + * Should use fcntl + O_NONBLOCK here ? */
> + continue;
> This is not such a rare case, we need to make sure a client doesn't
> trigger a 100% CPU loop.
> I think once we get EAGAIN or EWOULDBLOCK we should turn the socket into
> blocking mode
> (if it's not already) and restore the old state when we're done.
Agreed! The while+continue pair would lead to CPU busy looping
if EAGAIN is keeping prompt.
After lookup the ERRORS section about splice(2) man page,
it does not mention the EAGAIN.
This is a little interesting,
i did see strace log said splice return -1 with errno = EAGAIN,
if over a high-latency network with RTT = 500ms.
(This network is setup through WANem,
manually keep clicking the 'Apply settings' button)
More information about the samba-technical