svn commit: samba r3937 - in trunk/source/smbd: .

jra at samba.org jra at samba.org
Wed Nov 24 05:32:26 GMT 2004


Author: jra
Date: 2004-11-24 05:32:26 +0000 (Wed, 24 Nov 2004)
New Revision: 3937

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=3937

Log:
Remove partial check-in of sendfile on linux fix (committed in error).
Jeremy.

Modified:
   trunk/source/smbd/reply.c


Changeset:
Modified: trunk/source/smbd/reply.c
===================================================================
--- trunk/source/smbd/reply.c	2004-11-24 05:24:38 UTC (rev 3936)
+++ trunk/source/smbd/reply.c	2004-11-24 05:32:26 UTC (rev 3937)
@@ -1717,7 +1717,7 @@
  Fail for readbraw.
 ****************************************************************************/
 
-static void fail_readraw(void)
+void fail_readraw(void)
 {
 	pstring errstr;
 	slprintf(errstr, sizeof(errstr)-1, "FAIL ! reply_readbraw: socket write fail (%s)",
@@ -1725,46 +1725,12 @@
 	exit_server(errstr);
 }
 
-#if defined(WITH_SENDFILE)
 /****************************************************************************
- Fake (read/write) sendfile. Returns -1 on read or write fail.
-****************************************************************************/
-
-static ssize_t fake_sendfile(files_struct *fsp, SMB_OFF_T startpos, size_t nread, char *buf, int bufsize)
-{
-	ssize_t ret=0;
-
-	/* Paranioa check... */
-	if (nread > bufsize) {
-		fail_readraw();
-	}
-
-	if (nread > 0) {
-		ret = read_file(fsp,buf,startpos,nread);
-		if (ret == -1) {
-			return -1;
-		}
-	}
-
-	/* If we had a short read, fill with zeros. */
-	if (ret < nread) {
-		memset(outbuf, '\0', nread - ret);
-	}
-
-	if (write_data(smbd_server_fd(),buf,nread) != nread) {
-		return -1;
-	}	
-
-	return (ssize_t)nread;
-}
-#endif
-
-/****************************************************************************
  Use sendfile in readbraw.
 ****************************************************************************/
 
 void send_file_readbraw(connection_struct *conn, files_struct *fsp, SMB_OFF_T startpos, size_t nread,
-		ssize_t mincount, char *outbuf, int out_buffsize)
+		ssize_t mincount, char *outbuf)
 {
 	ssize_t ret=0;
 
@@ -1786,21 +1752,12 @@
 
 		if ( SMB_VFS_SENDFILE( smbd_server_fd(), fsp, fsp->fd, &header, startpos, nread) == -1) {
 			/*
-			 * Special hack for broken Linux with no working sendfile. If we
-			 * return EINTR we sent the header but not the rest of the data.
-			 * Fake this up by doing read/write calls.
+			 * 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 == EINTR) {
-				/* Ensure we don't do this again. */
+			if (errno == ENOSYS) {
 				set_use_sendfile(SNUM(conn), False);
-				DEBUG(0,("send_file_readbraw: sendfile not available. Faking..\n"));
-
-				if (fake_sendfile(fsp, startpos, nread, outbuf + 4, out_buffsize - 4) == -1) {
-					DEBUG(0,("send_file_readbraw: fake_sendfile failed for file %s (%s).\n",
-						fsp->fsp_name, strerror(errno) ));
-					exit_server("send_file_readbraw fake_sendfile failed");
-				}
-				return;
+				goto normal_read;
 			}
 
 			DEBUG(0,("send_file_readbraw: sendfile failed for file %s (%s). Terminating\n",
@@ -1810,6 +1767,7 @@
 
 	}
 
+  normal_read:
 #endif
 
 	if (nread > 0) {
@@ -1832,7 +1790,7 @@
  Reply to a readbraw (core+ protocol).
 ****************************************************************************/
 
-int reply_readbraw(connection_struct *conn, char *inbuf, char *outbuf, int dum_size, int out_buffsize)
+int reply_readbraw(connection_struct *conn, char *inbuf, char *outbuf, int dum_size, int dum_buffsize)
 {
 	extern struct current_user current_user;
 	ssize_t maxcount,mincount;
@@ -1947,7 +1905,7 @@
 	DEBUG( 3, ( "readbraw fnum=%d start=%.0f max=%d min=%d nread=%d\n", fsp->fnum, (double)startpos,
 				(int)maxcount, (int)mincount, (int)nread ) );
   
-	send_file_readbraw(conn, fsp, startpos, nread, mincount, outbuf, out_buffsize);
+	send_file_readbraw(conn, fsp, startpos, nread, mincount, outbuf);
 
 	DEBUG(5,("readbraw finished\n"));
 	END_PROFILE(SMBreadbraw);
@@ -2111,7 +2069,7 @@
  Reply to a read and X - possibly using sendfile.
 ****************************************************************************/
 
-int send_file_readX(connection_struct *conn, char *inbuf,char *outbuf,int length, int len_outbuf,
+int send_file_readX(connection_struct *conn, char *inbuf,char *outbuf,int length, 
 		files_struct *fsp, SMB_OFF_T startpos, size_t smb_maxcnt)
 {
 	ssize_t nread = -1;
@@ -2159,22 +2117,12 @@
 
 		if ( SMB_VFS_SENDFILE( smbd_server_fd(), fsp, fsp->fd, &header, startpos, smb_maxcnt) == -1) {
 			/*
-			 * Special hack for broken Linux with no working sendfile. If we
-			 * return EINTR we sent the header but not the rest of the data.
-			 * Fake this up by doing read/write calls.
+			 * 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 == EINTR) {
-				/* Ensure we don't do this again. */
+			if (errno == ENOSYS) {
 				set_use_sendfile(SNUM(conn), False);
-				DEBUG(0,("send_file_readX: sendfile not available. Faking..\n"));
-
-				if (fake_sendfile(fsp, startpos, smb_maxcnt, data,
-							len_outbuf - (data-outbuf)) == -1) {
-					DEBUG(0,("send_file_readX: fake_sendfile failed for file %s (%s).\n",
-						fsp->fsp_name, strerror(errno) ));
-					exit_server("send_file_readX: fake_sendfile failed");
-				}
-				return;
+				goto normal_read;
 			}
 
 			DEBUG(0,("send_file_readX: sendfile failed for file %s (%s). Terminating\n",
@@ -2187,6 +2135,8 @@
 		return -1;
 	}
 
+  normal_read:
+
 #endif
 
 	nread = read_file(fsp,data,startpos,smb_maxcnt);



More information about the samba-cvs mailing list