Boost logo

Boost Users :

From: Berserker (berserker_r_at_[hidden])
Date: 2008-06-13 04:29:22


In my project (using asio) I have something like this:

void Foo::myCallback(const boost::system::error_code &e)
{
     if(e == boost::asio::error::operation_aborted)
     {
         // bla bla...
     }
}

This call is made across a shared dll and I notice that for a "strange" reason e == boost::asio::error::operation_aborted was always false.

I discover that when the temporary object boost::system::error_code is constructed from the constants boost::asio::error::operation_aborted the error_code's costructor take a pointer to a "error_category" and the comparison operator is (m_cat is an error_category pointer):

inline friend bool operator==( const error_code & lhs, const error_code & rhs )
{
    return lhs.m_cat == rhs.m_cat && lhs.m_val == rhs.m_val;
}

In my situation (using shared modules) lhs.m_cat == rhs.m_cat points to differents memory regions (even if are of the same type "system_category") because of the static initialization in the function "get_system_category".
The problem exist in the comparison operator of error_category too:

bool operator==(const error_category & rhs) const { return this == &rhs; }

I suggest to change the comparison criteria (for example using an enumerated value)

_________________________________________________________________
Divertiti con le nuove EMOTICON per Messenger!
http://intrattenimento.it.msn.com/emoticon



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net