Branch: Tag:

2018-02-07

2018-02-07 16:28:18 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Filesystem.Monitor: Fix rescheduling by adjust_monitor().

adjust_monitor() didn't reschedule the backend_check() call_out
if the adjusted monitor already was at the head of monitor_queue.
This caused polls to be delayed in some common cases.

Fixes PIKE-64 (#8064).

1323:    mixed key = monitor_mutex->lock();    if (m->pos < 0) return; // Not on the monitor_queue any more (race).    -  Monitor next_monitor = monitor_queue->peek(); -  if (!next_monitor) { -  error("%O: Monitor queue is empty!\n", this_function); -  } -  -  int old_min = next_monitor->next_poll; +     monitor_queue->adjust(m); -  if (m->next_poll >= old_min) { +  if (monitor_queue->peek() != m) {    return;    }       if (co_id) {    // Nonblocking mode and we need to poll earlier,    // so reschedule the call_out. -  MON_WERR("Rescheduling call_out.\n"); -  if (backend) backend->remove_call_out(co_id); -  else remove_call_out(co_id); -  co_id = 0; -  set_nonblocking(); +  reschedule_backend_check();    }   }