svn commit: samba r7025 - in branches/SAMBA_3_0/source: lib tdb

Jeremy Allison jra at samba.org
Fri May 27 18:34:44 GMT 2005


On Fri, May 27, 2005 at 02:01:13PM -0400, derrell at samba.org wrote:
> 
> It seems to me that read_socket_data() should not return -1 if any data has
> been successfully read and sys_read() returns -1 and errno is EAGAIN or EINTR.
> Instead, it should return 'total', the amount of data read so far.  This
> changes the semantics of read_socket_data(), though (although
> read_socket_data() in combination with receive_smb_raw() is already broken).
> 
> The alternative that I think maybe you're proposing is for read_socket_data()
> to look at errno and if EAGAIN and EINTR, continue looping (which would make
> the additional code in receive_smb_raw() unnecessary.
> 
> Which of these (or some other alternative) do you prefer?  I'll incorporate
> whatever we decide on today.

Yes I think I prefer to fix the semantics of read_socket_data() so that
it fulfills the contract it's promising to callers. That should be simpler,
in that we just need to handle EAGAIN as an error code and go around the
loop instead of erroring out.

How about this as a patch instead ? The only thing we'd need to add is
an abort after XX times around the loop so stop us getting stuck forever
on a socket returning EAGAIN.

This is a much simpler change and doesn't modify any semantics (IMHO).

Jeremy.
-------------- next part --------------
Index: lib/util_sock.c
===================================================================
--- lib/util_sock.c	(revision 7035)
+++ lib/util_sock.c	(working copy)
@@ -430,6 +430,10 @@
 		}
 
 		if (ret == -1) {
+			if (errno == EAGAIN) {
+				/* On EAGAIN just loop back into sys_read. */
+				continue;
+			}
 			DEBUG(0,("read_socket_data: recv failure for %d. Error = %s\n", (int)(N - total), strerror(errno) ));
 			smb_read_error = READ_ERROR;
 			return -1;


More information about the samba-technical mailing list