[PATCH] disable sendfile on ENOSYS

James Peach jpeach at sgi.com
Fri Aug 6 06:45:25 GMT 2004


Hi all,

The attached patch flips the "use sendfile" parameter off if we find out
at runtime that it sendfile isn't present or doesn't work (ie. we get an
ENOSYS for it).

cheers,

-- 
James Peach | jpeach at sgi.com | SGI Australian Software Group
I don't speak for SGI.
-------------- next part --------------
diff -r -u reference/source/param/loadparm.c samba-3.0.5rc1/source/param/loadparm.c
--- reference/source/param/loadparm.c	Fri Jul  9 03:06:11 2004
+++ samba-3.0.5rc1/source/param/loadparm.c	Fri Aug  6 16:12:35 2004
@@ -4323,6 +4323,19 @@
 	return (_lp_use_sendfile(snum) && !srv_is_signing_active());
 }
 
+
+/*******************************************************************
+ Turn off sendfile if we find the underlying OS doesn't support it.
+********************************************************************/
+
+void set_use_sendfile(int snum, BOOL val)
+{
+	if (LP_SNUM_OK(snum))
+		ServicePtrs[snum]->bUseSendfile = val;
+	else
+		sDefault.bUseSendfile = val;
+}
+
 /*******************************************************************
  Turn off storing DOS attributes if this share doesn't support it.
 ********************************************************************/
diff -r -u reference/source/smbd/reply.c samba-3.0.5rc1/source/smbd/reply.c
--- reference/source/smbd/reply.c	Fri Jul  9 03:06:10 2004
+++ samba-3.0.5rc1/source/smbd/reply.c	Fri Aug  6 16:09:44 2004
@@ -1748,8 +1751,10 @@
 			 * Special hack for broken Linux with no 64 bit clean sendfile. If we
 			 * return ENOSYS then pretend we just got a normal read.
 			 */
-			if (errno == ENOSYS)
+			if (errno == ENOSYS) {
+				set_use_sendfile(SNUM(conn), False);
 				goto normal_read;
+			}
 
 			DEBUG(0,("send_file_readbraw: sendfile failed for file %s (%s). Terminating\n",
 				fsp->fsp_name, strerror(errno) ));
@@ -2111,8 +2116,10 @@
 			 * Special hack for broken Linux with no 64 bit clean sendfile. If we
 			 * return ENOSYS then pretend we just got a normal read.
 			 */
-			if (errno == ENOSYS)
+			if (errno == ENOSYS) {
+				set_use_sendfile(SNUM(conn), False);
 				goto normal_read;
+			}
 
 			DEBUG(0,("send_file_readX: sendfile failed for file %s (%s). Terminating\n",
 				fsp->fsp_name, strerror(errno) ));


More information about the samba-technical mailing list