[Ace-users] [ace-users] ACE_SOCK_Stream::recv_n() returns -1 if interrupted by signal

Jules d'Entremont Jules.dEntremont at SolaceSystems.com
Thu Oct 25 08:06:23 CDT 2007

> > If ACE_SOCK_Stream::recv_n() is interrupted by a signal, it returns
-1 and sets errno to EINTR.  Since this function is
> > expected to retry in case of a short read, it would be better for
the function to continue when interrupted, up to the time
> > specified in the timeout.
> I don't think a signal is the same thing as a short read, so this fix
> would be making too much of a "policy" decision that may not be wanted
> by all users by default.  Can't you simply use ACE_Sig_Action to
> the signal(s)?  I think this will have the same effect without
> existing semantics/programs.

I don't have control over which signals are being used by the
application (I'm developing an SDK which is used by others).  In fact,
in this case, the signal (SIGALRM) is used by the application, so it
can't be ignored.

As it is, I'm forced to write the following function and use it instead
of ACE_SOCK_Stream::recv_n():

        ACE_SOCK_Stream& sock, 
        void* buf, 
        size_t len, 
        const ACE_Time_Value* timeout)
        ssize_t retval = 0;
            retval = sock.recv_n(buf, len, timeout);
        } while ((retval == -1) && (errno == EINTR));
        return retval;

To me, this seems to defeat the purpose of ACE_SOCK_Stream::recv_n().


> Thanks,
> Doug

More information about the Ace-users mailing list