activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matvey Aizenshtat (JIRA)" <j...@apache.org>
Subject [jira] Created: (AMQCPP-107) SocketInputStream::read() doesn't check for EINTR error
Date Mon, 23 Apr 2007 13:48:34 GMT
SocketInputStream::read() doesn't check for EINTR error
-------------------------------------------------------

                 Key: AMQCPP-107
                 URL: https://issues.apache.org/activemq/browse/AMQCPP-107
             Project: ActiveMQ C++ Client
          Issue Type: Bug
          Components: CMS Impl
    Affects Versions: 2.0
         Environment: UNIX / POSIX
            Reporter: Matvey Aizenshtat
         Assigned To: Nathan Mittler
            Priority: Minor


>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 above is needed to avoid the situation when blocking read() call was failed due to the
interruption by a signal. 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message