activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Olivier Langlois <Olivier.Langl...@streamtheworld.com>
Subject ResponseCorrelator::request() exception safety concern in SVN trunk
Date Mon, 16 Nov 2009 22:39:09 GMT
Hi,

It seems to me that since the function oneway() and futureResponse::getResponse() can throw
exceptions, the code should make sure that the requestMap is cleared in all cases. I would
propose something like:

try
{
        // Send the request.
        next->oneway( command );

        // Get the response.
        response = futureResponse->getResponse( timeout );
}
catch(.)
{
        // Perform cleanup on the map.
        synchronized( &mapMutex ){

            // We do not want memory corruption by accessing freed
            // futureResponse objects by accident in onCommand() - get this thing out
            // of the map.
            requestMap.erase( command->getCommandId() );
        }
       throw;
}
synchronized( &mapMutex ){

    // We've done our waiting - get this thing out
    // of the map.
    requestMap.erase( command->getCommandId() );
}

Olivier Langlois
C++ Technical Lead

STREAMTHEWORLD

t. 1 866 448 4037 ext. 675
t. 1 514 448 4037 ext. 675
f. 1 514 807 1861

olivier.langlois@streamtheworld.com
streamtheworld.com
 
StreamTheWorld launches its new BlackBerry application. Learn more


Mime
View raw message