help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] non-blocking pipe read issue


From: Paolo Bonzini
Subject: Re: [Help-smalltalk] non-blocking pipe read issue
Date: Thu, 02 Feb 2012 13:39:41 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111222 Thunderbird/9.0

On 02/02/2012 01:02 PM, Derek Zhou wrote:
RETSIGTYPE
file_polling_handler (int sig)
{
   if (num_used_pollfds>  0)
     {
       _gst_disable_interrupts (true);
       _gst_async_call (async_signal_polled_files, NULL);
       _gst_enable_interrupts (true);
     }

   _gst_set_signal_handler (sig, file_polling_handler);
   _gst_wakeup ();
}

...
   set_file_interrupt (fd, file_polling_handler);

   /* Now check if I/O was made possible while setting up our machinery...
      If so, exit; otherwise, wait on the semaphore and the SIGIO
      will wake us up.  */

   result = _gst_sync_file_polling (fd, cond);
   if (result == 0)
     {
       if (!head)
         head = new;
       else
         *p_tail_next = new;
       p_tail_next =&new->next;

       num_used_pollfds++;
       _gst_register_oop (semaphoreOOP);
       _gst_sync_wait (semaphoreOOP);
     }
   else
     xfree (new);
...

Although it does a second poll after the sig handler setup trying to catch
this possibility, the data could still come in after the second poll but
before the _gst_sync_wait. The sig handler will trigger but it does not
prevent the process going to sleep.

 From the look of it the problem is not limited to pipes, the same could
happen to sockets as well.

Huh, the race is of course on setting num_used_pollfds. Stupid me. Holger, can you give the attached patch a try?

Paolo

Attachment: fix.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]