Branch: Tag:

2016-01-22

2016-01-22 18:23:00 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Process: Reduced impact of do_poll() race-condition.

The do_poll_loop() call_out loop and synchronous wait() may interfere
with each other. If do_poll_loop() eats the last message on the process_fd
after wait() has checked __status, then the do_poll() call from wait()
will hang until the timeout expires.

Decreases the maximum do_poll() timeout in wait() from 3600.0 to 1.0 seconds.

Likely to improve behaviour of [bug 6153].

The proper fix is probably to move do_poll_loop() to a dedicated thread and
use thread signalling to wake up the synchronous calls.

348: Inside #if constant(Stdio.__HAVE_SEND_FD__)
   };    // Filter errors about the backend already running.    if (arrayp(err) && sizeof(err) && -  stringp(err[0]) && has_prefix(err[0], "Backend already ")) return; +  stringp(err[0]) && has_prefix(err[0], "Backend already ")) { +  sleep(t); +  return; +  }    throw(err);    }   
375: Inside #if constant(Stdio.__HAVE_SEND_FD__)
   int wait()    {    if (process_backend) { -  do_poll(0.0); -  while (__status <= 0) { -  do_poll(3600.0); -  } +  float t = 0.0; +  do { +  do_poll(t); +  if (t < 1.0) t += 0.1; +  } while (__status <= 0);    return __result;    }    return ::wait();