activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mittler, Nathan" <nathan.mitt...@sensis.com>
Subject RE: SocketInputStream::read
Date Mon, 23 Apr 2007 13:09:31 GMT
Would you mind capturing this in a JIRA issue? 

> -----Original Message-----
> From: Motl [mailto:motl@orcsoftware.com] 
> Sent: Monday, April 23, 2007 8:56 AM
> To: dev@activemq.apache.org
> Subject: SocketInputStream::read
> 
> 
> From SocketInputSream.cpp:
> 
>     int len = ::recv(socket, (char*)buffer, (int)bufferSize, 0);
>     
>     // Check for a closed socket.
>     if( len == 0 ){
>         throw IOException( __FILE__, __LINE__, 
>             "activemq::io::SocketInputStream::read - The 
> connection is broken" );
>     }
>     
>     // Check for error.
>     if( len == -1 ){
>         
>         // Otherwise, this was a bad error - throw an exception.
>         throw IOException( __FILE__, __LINE__, 
>                 "activemq::io::SocketInputStream::read - %s",
> SocketError::getErrorString().c_str() );
>     }
> 
> It's really worth to replace the condition check with smth like this:
> 
> while( errno == EINTR)
> {
>       int len = ::recv(socket, (char*)buffer, (int)bufferSize, 0);
>     
>     if( len == 0 ){
>     ...
>     }
>     
>     if( len == -1 ){
>     ...
>     }
> 
> }
> 
> The abov is needed to avoid the situation when blocking 
> read() call was failed due to interruption by a signal.
> 
> --
> View this message in context: 
> http://www.nabble.com/SocketInputStream%3A%3Aread-tf3631398s23
> 54.html#a10139680
> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
> 
> 

Mime
View raw message