dlls/ntdll/sync.c
/***********************************************************************
 *              wait_reply
 *
 * Wait for a reply on the waiting pipe of the current thread.
 */
wait_reply
Wait for a reply on the waiting pipe of the current thread.
wait_reply Wait for a reply on the waiting pipe of the current thread .
static int wait_reply( void *cookie )
{
    int signaled;
    struct wake_up_reply reply;
    for (;;)
    {
        int ret;
        ret = read( ntdll_get_thread_data()->wait_fd[0], &reply, sizeof(reply) );
        if (ret == sizeof(reply))
        {
            if (!reply.cookie) abort_thread( reply.signaled );  
            if (wine_server_get_ptr(reply.cookie) == cookie) return reply.signaled;
            signaled = wait_reply( cookie );
            for (;;)
            {
                ret = write( ntdll_get_thread_data()->wait_fd[1], &reply, sizeof(reply) );
                if (ret == sizeof(reply)) break;
                if (ret >= 0) server_protocol_error( "partial wakeup write %d\n", ret );
                if (errno == EINTR) continue;
                server_protocol_perror("wakeup write");
            }
            return signaled;
        }
        if (ret >= 0) server_protocol_error( "partial wakeup read %d\n", ret );
        if (errno == EINTR) continue;
        server_protocol_perror("wakeup read");
    }
}
static int wait_reply ( void * cookie ) { int signaled ; struct wake_up_reply reply ; for ( ; ; ) { int ret ; ret = read ( ntdll_get_thread_data ( ) -> wait_fd [ 0 ] , & reply , sizeof ( reply ) ) ; if ( ret == sizeof ( reply ) ) { if ( ! reply . cookie ) abort_thread ( reply . signaled ) ; if ( wine_server_get_ptr ( reply . cookie ) == cookie ) return reply . signaled ; signaled = wait_reply ( cookie ) ; for ( ; ; ) { ret = write ( ntdll_get_thread_data ( ) -> wait_fd [ 1 ] , & reply , sizeof ( reply ) ) ; if ( ret == sizeof ( reply ) ) break ; if ( ret >= 0 ) server_protocol_error ( " \n " , ret ) ; if ( errno == EINTR ) continue ; server_protocol_perror ( " " ) ; } return signaled ; } if ( ret >= 0 ) server_protocol_error ( " \n " , ret ) ; if ( errno == EINTR ) continue ; server_protocol_perror ( " " ) ; } }
wait_reply
 Wait for a reply on the waiting pipe of the current thread.
wait_reply Wait for a reply on the waiting pipe of the current thread .
/* thread got killed */ /* we stole another reply, wait for the real one */ /* and now put the wrong one back in the pipe */