Boost logo

Boost Users :

Subject: [Boost-users] asio: i/o cancellation under Linux/ARM broken?
From: Stefan Sichler (stsichler_at_[hidden])
Date: 2008-11-21 10:41:17


Hello,

I'm developing a major application using asio that is ported to Windows
x86/ia64, Linux x86 and Linux on an ARM processor.
It seems i/o cancellation is broken on Linux/ARM, which is a major problem
for me.

I added a small test case below for demonstration. On Windows, the test case
will work correctly, running the loop 10 times. On Linux, it will hang after
the first loop pass.

Please help!

(boost 1.37, Debian Linux 2.6.27)

Regards,
Stefan Sichler

>> code follows:

#ifdef WIN32
#define BOOST_ASIO_ENABLE_CANCELIO
#endif

#include <iostream>
#include <boost/asio.hpp>

using namespace std;
using namespace boost::asio;
using namespace boost::asio::ip;

// boost asio cancellation testcase

bool g_io_completed= false;

void completionHandler(const boost::system::error_code& err, size_t bt) {
        cout<<"completed err="<<err<<" bt="<<bt<<endl;
        g_io_completed= true;
}

int main(int argc, char* argv[])
{
        io_service ios;
        udp::socket sock(ios);
        sock.open(udp::v4());
        sock.bind(udp::endpoint());

        cout<<"note: if this test hangs, the cancel test failed!"<<endl;

        char buf[64];

        for (int i=0; i<10; ++i)
        {
                cout<<"loop start i="<<i<<endl;
                g_io_completed= false;
                sock.async_receive(buffer(buf),completionHandler);

                for (int t=0; t<1000; ++t) // spend some time....
                        ios.poll();

                sock.cancel();

                while (!g_io_completed) // wait for completion handler
                        ios.poll();

                cout<<"loop end i="<<i<<endl;
        }

        cout<<"cancel test completed successfully!"<<endl;

        return 0;
}


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