public inbox for ecos-maintainers@sourceware.org
 help / color / mirror / Atom feed
* FWD: [ECOS] Only return EWOULDBLOCK if no data moved
@ 2004-02-16 15:53 Andrew Lunn
  2004-02-16 16:05 ` Jonathan Larmour
  2004-02-16 16:14 ` Nick Garnett
  0 siblings, 2 replies; 3+ messages in thread
From: Andrew Lunn @ 2004-02-16 15:53 UTC (permalink / raw)
  To: eCos Maintainers

Hi Folks

What do people think about this patch? 

Should be apply it, or try to fix the network stack?

       Thanks
          Andrew


----- Forwarded message from Roland Ca?ebohm <roland.cassebohm@visionsystems.de> -----

From: Roland Ca?ebohm <roland.cassebohm@visionsystems.de>
To: ecos-discuss@ecos.sourceware.org
Date: Tue, 27 Jan 2004 18:03:26 +0100
Subject: [ECOS] Only return EWOULDBLOCK if no data moved
X-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00 autolearn=ham 
	version=2.63

Hello,

both TCP/IP stacks could return EWOULDBLOCK even if there are data moved
in some cases.
My first solution was the attached patch, but maybe it is better to fix
the problem in the stacks it self?

I have seen there was a semilar problem in the serial driver:

2003-03-20  Gary Thomas  <gary@mlbassoc.com>

        * src/common/serial.c: Only return -EAGAIN if no data moved.

The attached patch would fix it for all possible places where something
like this could happen.

Any suggestions?

Roland

Index: io/fileio/current/src/io.cxx
===================================================================
RCS file: /home/cassebohm/net/USERS/CVSROOT/VSprojects/ecos/packages/io/fileio/current/src/io.cxx,v
retrieving revision 1.1.1.1.2.1
diff -u -5 -p -r1.1.1.1.2.1 io.cxx
--- io/fileio/current/src/io.cxx	12 Nov 2003 10:57:18 -0000	1.1.1.1.2.1
+++ io/fileio/current/src/io.cxx	27 Jan 2004 16:50:50 -0000
@@ -144,11 +144,16 @@ readwritev( int fd, const cyg_iovec *_io
     cyg_fp_free( fp );
 
     CYG_CANCELLATION_POINT;
 
     if( ret != 0 )
-        FILEIO_RETURN(ret);
+    {
+        if ((ret == EWOULDBLOCK || ret == EAGAIN) && cnt)
+            FILEIO_RETURN_VALUE(cnt);
+        else
+            FILEIO_RETURN(ret);
+    }
  
     FILEIO_RETURN_VALUE(cnt);
 }
 
 //==========================================================================


-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss

----- End forwarded message -----

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: FWD: [ECOS] Only return EWOULDBLOCK if no data moved
  2004-02-16 15:53 FWD: [ECOS] Only return EWOULDBLOCK if no data moved Andrew Lunn
@ 2004-02-16 16:05 ` Jonathan Larmour
  2004-02-16 16:14 ` Nick Garnett
  1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Larmour @ 2004-02-16 16:05 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: eCos Maintainers

Andrew Lunn wrote:
> Hi Folks
> 
> What do people think about this patch? 
> 
> Should be apply it, or try to fix the network stack?

The patch is correct. POSIX says for read() in relation to return values:

[EAGAIN] or [EWOULDBLOCK]: The file descriptor is for a connection-made 
socket, is marked O_NONBLOCK, and no data is waiting to be received.

In the case considered, some data is waiting to be received, so 
EAGAIN/EWOULDBLOCK is the wrong thing to return.

Jifl


> ----- Forwarded message from Roland Ca?ebohm <roland.cassebohm@visionsystems.de> -----
> 
> From: Roland Ca?ebohm <roland.cassebohm@visionsystems.de>
> To: ecos-discuss@ecos.sourceware.org
> Date: Tue, 27 Jan 2004 18:03:26 +0100
> Subject: [ECOS] Only return EWOULDBLOCK if no data moved
> X-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00 autolearn=ham 
> 	version=2.63
> 
> Hello,
> 
> both TCP/IP stacks could return EWOULDBLOCK even if there are data moved
> in some cases.
> My first solution was the attached patch, but maybe it is better to fix
> the problem in the stacks it self?
> 
> I have seen there was a semilar problem in the serial driver:
> 
> 2003-03-20  Gary Thomas  <gary@mlbassoc.com>
> 
>         * src/common/serial.c: Only return -EAGAIN if no data moved.
> 
> The attached patch would fix it for all possible places where something
> like this could happen.



> Any suggestions?
> 
> Roland
> 
> Index: io/fileio/current/src/io.cxx
> ===================================================================
> RCS file: /home/cassebohm/net/USERS/CVSROOT/VSprojects/ecos/packages/io/fileio/current/src/io.cxx,v
> retrieving revision 1.1.1.1.2.1
> diff -u -5 -p -r1.1.1.1.2.1 io.cxx
> --- io/fileio/current/src/io.cxx	12 Nov 2003 10:57:18 -0000	1.1.1.1.2.1
> +++ io/fileio/current/src/io.cxx	27 Jan 2004 16:50:50 -0000
> @@ -144,11 +144,16 @@ readwritev( int fd, const cyg_iovec *_io
>      cyg_fp_free( fp );
>  
>      CYG_CANCELLATION_POINT;
>  
>      if( ret != 0 )
> -        FILEIO_RETURN(ret);
> +    {
> +        if ((ret == EWOULDBLOCK || ret == EAGAIN) && cnt)
> +            FILEIO_RETURN_VALUE(cnt);
> +        else
> +            FILEIO_RETURN(ret);
> +    }
>   
>      FILEIO_RETURN_VALUE(cnt);
>  }
>  
>  //==========================================================================
> 
> 


-- 
eCosCentric    http://www.eCosCentric.com/    The eCos and RedBoot experts
Visit us at Embedded World 2004, Nürnberg, Germany, 17-19 Feb, Stand 12-449
--["No sense being pessimistic, it wouldn't work anyway"]-- Opinions==mine

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: FWD: [ECOS] Only return EWOULDBLOCK if no data moved
  2004-02-16 15:53 FWD: [ECOS] Only return EWOULDBLOCK if no data moved Andrew Lunn
  2004-02-16 16:05 ` Jonathan Larmour
@ 2004-02-16 16:14 ` Nick Garnett
  1 sibling, 0 replies; 3+ messages in thread
From: Nick Garnett @ 2004-02-16 16:14 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: eCos Maintainers

Andrew Lunn <andrew@lunn.ch> writes:

> Hi Folks
> 
> What do people think about this patch? 
> 
> Should be apply it, or try to fix the network stack?

I think it is OK to apply this patch as it stands. In theory it makes
it slightly easier to write filesystems/devices/netstacks. However,
since EWOULDBLOCK and EAGAIN are actually synonyms, there is no need
to check for both.

-- 
Nick Garnett                    eCos Kernel Architect
http://www.ecoscentric.com      The eCos and RedBoot experts

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-02-16 16:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-16 15:53 FWD: [ECOS] Only return EWOULDBLOCK if no data moved Andrew Lunn
2004-02-16 16:05 ` Jonathan Larmour
2004-02-16 16:14 ` Nick Garnett

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).