[Ace-users] [ace-users] ACE_SOCK_Stream::recv_n() returns -1 if interrupted by signal
Douglas C. Schmidt
schmidt at dre.vanderbilt.edu
Thu Oct 25 14:32:07 CDT 2007
Hi Jules,
>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.
Assuming that you are running in an OS that supports the POSIX thread
API, you should be able to block signals in the thread that does the
read. That should solve your problem.
>As it is, I'm forced to write the following function and use it instead
>of ACE_SOCK_Stream::recv_n():
>
> ssize_t
> recv_n(
> ACE_SOCK_Stream& sock,=20
> void* buf,=20
> size_t len,=20
> const ACE_Time_Value* timeout)
> {
> ssize_t retval =3D 0;
> =20
> do=20
> {
> retval =3D sock.recv_n(buf, len, timeout);
> } while ((retval =3D=3D -1) && (errno =3D=3D EINTR));
> =20
> return retval;
> }
>
>To me, this seems to defeat the purpose of ACE_SOCK_Stream::recv_n().
The problem with your suggested fix is that it breaks current semantics.
The easiest way to solve this is via the APIs that ACE supports that
can block signals in a particular thread. It would also be possible
to parameterize ACE_SOCK_Stream so that it could conditionally ignore
signals, but that will have broader side-effects.
Take care,
Doug
--
Dr. Douglas C. Schmidt Professor and Associate Chair
Electrical Engineering and Computer Science TEL: (615) 343-8197
Vanderbilt University WEB: www.dre.vanderbilt.edu/~schmidt
Nashville, TN 37203 NET: d.schmidt at vanderbilt.edu
More information about the Ace-users
mailing list