[Ace-users] [ace-users] ACE_SOCK_Stream: receiving a SIGPIPE message whentrying to use send_n()

Steve Huston shuston at riverace.com
Mon Feb 25 16:50:52 CST 2008


Hi Jim,

> Thanks, I'll check it out. Are there more resources online and
> sites devoted to ACE and its use that I just can't find via Google?

There are a few places to check - I can't say whether they're all
crawled by Google:

1. Doug Schmidt's ACE page, http://www.cs.wustl.edu/~schmidt/ACE.html
2. Riverace's ACE Knowledge Base, http://www.riverace.com/ace-kb.htm
3. Reference pages at http://www.dre.vanderbilt.edu/Doxygen/

> It seems like everything about ACE comes from a set of 3 books.

Those books are the most authoritative and explanatory source of
information on ACE. Just think if you were trying this without the
books ;-)

Best regards,
-Steve


On Feb 25, 2008, at 4:52 PM, Steve Huston wrote:


Hi Jim,

SIGPIPE is raised if you try to send into a closed connection; it's
not a bug in ACE. Please see C++NPv2 pages 173-174 for an example of
how to prevent this situation.

-Steve
--
Steve Huston, Riverace Corporation
Want to take ACE training on YOUR schedule?
See http://www.riverace.com/training.htm

-----Original Message-----
From: ace-users-bounces at cse.wustl.edu
[mailto:ace-users-bounces at cse.wustl.edu] On Behalf Of Jim Hodapp
Sent: Monday, February 25, 2008 4:27 PM
To: ace-users at cs.wustl.edu
Subject: [ace-users] ACE_SOCK_Stream: receiving a SIGPIPE message
whentrying to use send_n()


ACE VERSION: 5.6.2

    HOST MACHINE and OPERATING SYSTEM:
        Dell Optiplex GX270, Ubuntu Linux 7.10

    TARGET MACHINE and OPERATING SYSTEM, if different from HOST:
        Same as HOST

    COMPILER NAME AND VERSION (AND PATCHLEVEL):
        g++ v4.2.1

    THE $ACE_ROOT/ace/config.h FILE [if you use a link to a platform-
    specific file, simply state which one]:
        As packaged by the Debian experimental branch binary and dev
packages.

    THE $ACE_ROOT/include/makeinclude/platform_macros.GNU FILE [if you
    use a link to a platform-specific file, simply state which one
    (unless this isn't used in this case, e.g., with Microsoft Visual
    C++)]:
         As packaged by the Debian experimental branch binary and dev
packages.

    CONTENTS OF
$ACE_ROOT/bin/MakeProjectCreator/config/default.features
    (used by MPC when you generate your own makefiles):
        As packaged by the Debian experimental branch binary and dev
packages.

    AREA/CLASS/EXAMPLE AFFECTED:
        N/A

    DOES THE PROBLEM AFFECT:
        The problem affects execution and I believe the problem is in
libACE's ACE_SOCK_Stream::send_n() member function.

    SYNOPSIS:
        After setting up a successful connection using an
ACE_SOCK_Stream, about every-other execution of my app, I get a
SIGPIPE from my OS while trying to send data to a remote machine via
the ACE_SOCK_Stream::send_n() member function call.

    DESCRIPTION:
        After setting up a successful connection using an
ACE_SOCK_Stream, about every-other execution of my app, I get a
SIGPIPE from my OS while trying to send data to a remote machine via
the ACE_SOCK_Stream::send_n() member function call. My app sets up
multiple instances of my class called Connection. Each connection
inherits from ACE_Task<ACE_MT_SYNCH>. I have a loop where I call a
member function of my Connection class that sends a STL string to the
remote machine via TCP. About every other execution of my program
results in a SIGPIPE. Otherwise, on the other execution things works
fine. This seems like a timing issue or a multi-threaded issue, but it
appears like it might be a problem in send_n(). I would like an
opinion on if it is something I am doing in my code that might be an
invalid use of the ACE_SOCK_Stream or if this might be a bug in ACE. I
did a backtrace using gdb right after my app stopped via SIGPIPE and
is as follows:

#0  0xffffe410 in __kernel_vsyscall ()
#1  0xb7c35cfb in write () from /lib/tls/i686/cmov/libc.so.6
#2  0xb7e593d9 in ACE::send_n_i () from /usr/lib/libACE-5.6.2.so
#3  0x08067cce in ACE::send_n (handle=7, buf=0x80e3d34, len=368,
timeout=0xb63eafb0, bytes_transferred=0x0)
    at /usr/include/ace/ACE.inl:197
#4  0x08067d0d in ACE_SOCK_Stream::send_n (this=0x80ae3fc,
buf=0x80e3d34, len=368, timeout=0xb63eafb0, bytes_transferred=0x0)
    at /usr/include/ace/SOCK_Stream.inl:122
#5  0x08065205 in mcm::Connection::sendPayload (this=0x80ae398,
payload=0x80b5a50) at connection.cpp:302
#6  0x080600af in mcm::ConnectionManager::sendPayload (this=0x80ae430,
payload=0x80b5a50, connectionNumber=0)
    at connectionmanager.cpp:135
#7  0x08080dc0 in mcm::TestTimerHandler::sendRTSPSetup
(this=0xb7804000, connectionNumber=0, loadTest1=0x80abfd8)
    at testtimerhandler.cpp:137
#8  0x080816dc in mcm::TestTimerHandler::handle_timeout
(this=0xb7804000, currentTime=@0xb63eb280, arg=0x80abfd8)
    at testtimerhandler.cpp:80
#9  0x0807ed2b in
ACE_Event_Handler_Handle_Timeout_Upcall<ACE_Recursive_Thread_Mutex>::t
imeout (this=0x80a3680, 
    timer_queue=@0x80a37a0, event_handler=0xb7804000, act=0x80abfd8,
recurring_timer=1, cur_time=@0xb63eb280)
    at /usr/include/ace/Timer_Queue_T.cpp:412
#10 0x0807ee11 in ACE_Timer_Queue_T<ACE_Event_Handler*,
ACE_Event_Handler_Handle_Timeout_Upcall<ACE_Recursive_Thread_Mutex>,
ACE_Recursive_Thread_Mutex>::upcall (this=0x80a37a0, info=@0xb63eb224,
cur_time=@0xb63eb280) at /usr/include/ace/Timer_Queue_T.inl:170
#11 0x0807eecb in ACE_Timer_Queue_T<ACE_Event_Handler*,
ACE_Event_Handler_Handle_Timeout_Upcall<ACE_Recursive_Thread_Mutex>,
ACE_Recursive_Thread_Mutex>::expire (this=0x80a37a0,
cur_time=@0xb63eb280) at /usr/include/ace/Timer_Queue_T.cpp:274
#12 0x0807c972 in ACE_Timer_Queue_T<ACE_Event_Handler*,
ACE_Event_Handler_Handle_Timeout_Upcall<ACE_Recursive_Thread_Mutex>,
ACE_Recursive_Thread_Mutex>::expire (this=0x80a37a0) at
/usr/include/ace/Timer_Queue_T.inl:151
#13 0x0807d74f in
ACE_Thread_Timer_Queue_Adapter<ACE_Timer_Heap_T<ACE_Event_Handler*,
ACE_Event_Handler_Handle_Timeout_Upcall<ACE_Recursive_Thread_Mutex>,
ACE_Recursive_Thread_Mutex> >::svc (this=0x80ac058) at
/usr/include/ace/Timer_Queue_Adapters.cpp:282
#14 0xb7ef76a2 in ACE_Task_Base::svc_run () from
/usr/lib/libACE-5.6.2.so
#15 0xb7ef7908 in ACE_Thread_Adapter::invoke_i () from
/usr/lib/libACE-5.6.2.so
#16 0xb7ef7ad6 in ACE_Thread_Adapter::invoke () from
/usr/lib/libACE-5.6.2.so
#17 0xb7e6a501 in ace_thread_adapter () from /usr/lib/libACE-5.6.2.so
#18 0xb7b5f46b in start_thread () from
/lib/tls/i686/cmov/libpthread.so.0
#19 0xb7c456de in clone () from /lib/tls/i686/cmov/libc.so.6

The member function of my code that uses send_n() is as follows:

void Connection::sendPayload(Payload *payload) throw
(invalid_argument, TCPFailedToSend, TCPNotConnected)
{
    if (payload == NULL)
        throw invalid_argument("payload cannot be NULL.");
    if (payload->getPayload().empty())
        throw invalid_argument("payload must not be empty.");

    // Check the state of the TCP connection:
    this->checkConnection();
    assert(this->connected);

    // Reset any last error:
    ACE_OS::last_error(0);

    Logger::Instance().Debug1("Sending payload.", __FILE__, __LINE__);
    unsigned short n = 0;
    ACE_Time_Value sTimeout(this->sendTimeout);
    // Send exactly payload->getPayload().length() bytes via tcpStream
in sTimeout time:
    while (this->tcpStream.send_n(payload->getPayload().c_str(),
payload->getPayload().length(), &sTimeout) == -1)
    {
        // if (n == 10 && ACE_OS::last_error() == ETIME)
        //    throw TCPFailedToSend("Failed to send payload for
connection #"
        //                        +
Helper::intToString(this->connectionNumber) + " before timing out.",
        //                            __FILE__, __LINE__);
        if (ACE_OS::last_error() != ETIME && ACE_OS::last_error() !=
ECONNRESET || n == 10)
            throw TCPFailedToSend("Failed to send payload for
connection #"
                                +
Helper::intToString(this->connectionNumber)
                                + " before timing out. Reason: " +
strerror(errno),
                                __FILE__, __LINE__);
    }
    n++;
}

Thanks,

Jim




More information about the Ace-users mailing list