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

Douglas C. Schmidt schmidt at dre.vanderbilt.edu
Wed Oct 24 20:24:51 CDT 2007


Hi Jules,

   Thanks for using the PRF.

>     ACE VERSION: 5.5.1
> 
>     HOST MACHINE and OPERATING SYSTEM:
> 
> Linux dev228 2.6.17-1.2142_FC4smp #1 SMP Tue Jul 11 22:57:02 EDT 2006 i686 i686 i386 GNU/Linux
> 
>     TARGET MACHINE and OPERATING SYSTEM, if different from HOST:
> 
>     COMPILER NAME AND VERSION (AND PATCHLEVEL):
> 
>     THE $ACE_ROOT/ace/config.h FILE [if you use a link to a platform-specific file, simply state which one]:
> 
> #include "config-linux.h"
> 
>     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++)]:
> 
> platform_linux.GNU
> 
>     CONTENTS OF $ACE_ROOT/bin/MakeProjectCreator/config/default.features
> 
>     (used by MPC when you generate your own makefiles):
> 
>     AREA/CLASS/EXAMPLE AFFECTED:
> 
>     DOES THE PROBLEM AFFECT:
> 
>         COMPILATION?
> 
>         LINKING?
> 
>             On Unix systems, did you run make realclean first?
> 
>         EXECUTION?  yes
> 
>         OTHER (please specify)?
> 
>     SYNOPSIS:
> 
> ACE_SOCK_Stream::recv_n() returns -1 if interrupted by signal.
> 
>     DESCRIPTION:
> 
> 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 ignore
the signal(s)?  I think this will have the same effect without breaking
existing semantics/programs.

Thanks,

Doug

> I haven’t looked at send_n() to see if it suffers from the same problem.
> 
>     REPEAT BY:
> 
>     SAMPLE FIX/WORKAROUND:
> 
> The following patch is untested:
> 
> *** ACE.cpp     2006-03-14 16:15:48.000000000 -0500
> 
> --- ACE.cpp.new 2007-10-24 14:59:31.000000000 -0400
> 
> *************** ACE::recv_n_i (ACE_HANDLE handle,
> 
> *** 648,653 ****
> 
> --- 648,659 ----
> 
>                   }
> 
>               }
> 
> +           if (errno == EINTR)
> 
> +           {
> 
> +               n = 0;
> 
> +               continue;
> 
> +           }
> 
> +
> 
>             // Other data transfer or select() failures.
> 
>             return -1;
> 
>           }
> 
> *************** ACE::recv_n_i (ACE_HANDLE handle,
> 
> *** 685,690 ****
> 
> --- 691,702 ----
> 
>                           len - bytes_transferred,
> 
>                           flags);
> 
> +       if (n == -1 && errno == EINTR)
> 
> +       {
> 
> +           n = 0;
> 
> +           continue;
> 
> +       }
> 
> +      
> 
>         // Check for errors.
> 
>         if (n == 0 ||
> 
>             n == -1)
> 
> _______________________________________________
> ace-users mailing list
> ace-users at mail.cse.wustl.edu
> http://mail.cse.wustl.edu/mailman/listinfo/ace-users



More information about the Ace-users mailing list