public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jan Kasprzak <kas@informatics.muni.cz>
To: Jesse S Sipprell <jss@inflicted.net>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>,
	linux-kernel@vger.kernel.org, proftpd-devel@proftpd.org,
	pavel@janik.cz
Subject: Re: Possible problem with zero-copy TCP and sendfile()
Date: Tue, 17 Apr 2001 22:36:36 +0200	[thread overview]
Message-ID: <20010417223636.C2167@informatics.muni.cz> (raw)
In-Reply-To: <20010417170206.C2589096@informatics.muni.cz> <E14pXxg-0002cI-00@the-village.bc.nu> <20010417181524.E2589096@informatics.muni.cz> <20010417161036.A21620@bastard.inflicted.net>
In-Reply-To: <20010417161036.A21620@bastard.inflicted.net>; from jss@inflicted.net on Tue, Apr 17, 2001 at 04:10:36PM -0400

Jesse S Sipprell wrote:
: After cursory examination of proftpd, it appears that there is a misuse of the
: sendfile() call under Linux, which may be responsible for the corruption.  The
: code was originally based on BSD semantics.  Under Linux, the offset argument
: is not being used correctly to determine how much data has been sent in the
: case of EINTR.
: 
: A patch will be coming out soon, as it is a fairly trivial fix.
: 
	FWIW, I've fixed ProFTPd on my server with the following patch.
Sorry for making noise @ linux-kernel list, it was totally unrelated
to the Linux kernel:

--- proftpd-1.2.2rc1/src/data.c.sendfile	Thu Feb 15 15:24:53 2001
+++ proftpd-1.2.2rc1/src/data.c	Tue Apr 17 21:35:24 2001
@@ -760,7 +760,9 @@
      *
      * ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count)
      */
-    if((len = sendfile(session.d->outf->fd, retr_fd, offset, count)) == -1) {
+    len = sendfile(session.d->outf->fd, retr_fd, offset, count);
+    if (len == -1 || len > 0 && len < count) {
+       errno = EINTR;
 #elif defined(HAVE_BSD_SENDFILE)
     /* BSD semantics for sendfile are flexible...it'd be nice if we could
      * standardize on something like it.  The semantics are:
@@ -797,7 +799,9 @@
 	if((count -= len) <= 0)
 	  break;
 	
+#if !defined(HAVE_LINUX_SENDFILE)
 	*offset += len;
+#endif
 	
 	if(TimeoutStalled)
 	  reset_timer(TIMER_STALLED, ANY_MODULE);

-Yenya

-- 
\ Jan "Yenya" Kasprzak <kas at fi.muni.cz>       http://www.fi.muni.cz/~kas/
\\ PGP: finger kas at aisa.fi.muni.cz   0D99A7FB206605D7 8B35FCDE05B18A5E //
\\\             Czech Linux Homepage:  http://www.linux.cz/              ///
Mantra: "everything is a stream of bytes". Repeat until enlightened. --Linus

  parent reply	other threads:[~2001-04-17 20:37 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-17 13:10 Possible problem with zero-copy TCP and sendfile() Jan Kasprzak
2001-04-17 14:41 ` Andi Kleen
2001-04-17 15:50   ` Jan Kasprzak
     [not found]     ` <20010417175916.A11824@gruyere.muc.suse.de>
2001-04-17 17:07       ` Jan Kasprzak
2001-04-17 17:40         ` Jan Kasprzak
2001-04-17 14:48 ` Alan Cox
2001-04-17 15:02   ` Jan Kasprzak
2001-04-17 16:04     ` Alan Cox
2001-04-17 16:15       ` Jan Kasprzak
2001-04-17 18:24         ` Pekka Pietikainen
2001-04-17 20:10         ` Jesse S Sipprell
2001-04-17 20:23           ` David S. Miller
2001-04-17 20:44             ` Jesse S Sipprell
2001-04-17 20:50               ` David S. Miller
2001-04-17 20:36           ` Jan Kasprzak [this message]
2001-04-17 21:22             ` Wolfgang Rohdewald
2001-04-17 21:43               ` Martin Josefsson
2001-04-18  6:09               ` Jan Kasprzak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010417223636.C2167@informatics.muni.cz \
    --to=kas@informatics.muni.cz \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=jss@inflicted.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pavel@janik.cz \
    --cc=proftpd-devel@proftpd.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox