From jay@fork.rain.com Fri Aug 11 01:54:35 1995 Return-Path: jay@fork.rain.com Received: from fork.rain.com (root@fork.rain.com [204.119.8.43]) by locust.net.ohio-state.edu (8.6.12/8.6.9) with ESMTP id BAA29248 for ; Fri, 11 Aug 1995 01:54:28 -0400 Received: from fork.rain.com (loopback [127.0.0.1]) by fork.rain.com (8.6.11/8.6.9) with ESMTP id WAA05539 for ; Thu, 10 Aug 1995 22:52:46 -0700 Message-Id: <199508110552.WAA05539@fork.rain.com> To: maf@net.ohio-state.edu Subject: Re: Linux port of sendpage? In-reply-to: Your message of "Thu, 10 Aug 1995 23:14:26 EDT." <199508110314.XAA07252@bedbugs.net.ohio-state.edu> Date: Thu, 10 Aug 1995 22:52:45 -0700 From: "Jay D. Allen" Status: RO First of, thanks for contributing such a great program. I have the Linux port working now. The trick is that Linux was not blocking if 0 bytes was "immediately available". Read() returns -1, and sets errno=EAGIN="Try Again". Cute eh? Anyway, I just test for this case in SafeRead(), and then reset errno=0, and return a "0" to the caller. Oh, I also added a sleep(1) in that case. Seems to work just fine. This may be the case in Solaris2.4 as well.. It's hard to tell because I seem to be getting some clobered pointers. I'm working on it. Another interesting wrinkle, I have many instances of sendpage writing to a shared que directory (via NFS), then on yet another machine, sendpage running in daemon mode, servicing the que. I'm pleased to annouce that this scheme works very well. No deadlocks (yet). I'll send you my diffs, when I finish getting the Solaris2.4 version going. The linux-1.1.90 diffs are below. See ya, Jay Allen jay@fork.com P.S. When can we expect to see version 5? > >Do you know of anyone working on a port of sendpage for Linux? > > > >It compiles, and does run, but can not get past reseting the modem. > >The first thing I found was that even when a fd is set in NON_BLOCK, > >Linux read() will return -1, and set errno to EAGAIN if no bytes > >are read (instead of 0). Fixed, that, but still no good. > > Someone on the ixo list said they had it mostly working once. It's not > something I've had time port myself... > > There will be contributed osf/1 patches in alpha 5 which may end up > working for Linux > > -- > mark > maf+@osu.edu Diffs for Sendpage4 - UNAME=Linux 1.1.90 First, a little typo, I suppose? ================================ diff sendpage4.orig/io.c sendpage4/io.c 109,110c109 < t.c_cflag = pcinfo->speed|pcinfo->databits|pcinfo->parity|pcinfo->stopbits| < CREAD|C_FLAG; --- > t.c_cflag = pcinfo->speed|pcinfo->databits|pcinfo->parity|pcinfo->stopbits|C_FLAG; 241c240 < --- Here is the heart of what makes sendpage4 work under Linux ========================================================== > 402c401 < if ((n = read(fd, buf, len)) == -1) { --- > if (((n = read(fd, buf, len)) == -1) && (errno != EAGAIN) ) { 405a405,410 > if ((n == -1) && (errno == EAGAIN) ) { > errno = 0; > sleep(1); > return 0; > } > Sendpage4 header file for Linux ============================== diff sendpage4.orig/sendpage.h sendpage4/sendpage.h 5,6c5,6 < #define PATH_SENDPAGE_PIDFILE "/var/pqueue/sendpage.pid" < #define PATH_QUEUE "/var/pqueue" --- > #define PATH_SENDPAGE_PIDFILE "/pkgs/pqueue/sendpage.pid" > #define PATH_QUEUE "/pkgs/pqueue" 16c16 < #define SYSV_MALLOC /* #define SYSV_MALLOC /* (No for IRIX, no for Solaris) */ --- > /*#define SYSV_MALLOC *//* #define SYSV_MALLOC /* (No for IRIX, no for Solaris) */ 19c19 < #define NEED_MALLOC_H --- > /*#define NEED_MALLOC_H*/ 93c93 < #define MODEM_DEV "/dev/ttyb" --- > #define MODEM_DEV "/dev/modem" 100,101c100,102 < #define C_FLAG CRTSCTS|HUPCL /* enable RTS/CTS flow control */ < /* #define C_FLAG HUPCL /**/ --- > #define C_FLAG CRTSCTS|HUPCL /* enable RTS/CTS flow control */ > /*#define C_FLAG HUPCL */ /**/ > /*#define C_FLAG CLOCAL /**/ 104c105 < #define TOGGLE_DTR --- > /*#define TOGGLE_DTR*/ 116c117 < #define MODEM_WORD_OK "OK\r" --- > #define MODEM_WORD_OK "\r\nOK"