Commit 046e0844 authored by Henrik (Grubba) Grubbström's avatar Henrik (Grubba) Grubbström
Browse files

Inotify: Improved initialization in add_watch().

Make sure that the backend is woken up after scheduling the
artifical initialization events. Otherwise they may stay
pending indefinitely.
parent cf70fbb0
......@@ -192,6 +192,24 @@ PIKECLASS _Instance {
identifier_flags |= IDENTIFIER_NO_THIS_REF;
}
static void check_schedule_poll(void)
{
if (THIS->box.events & PIKE_BIT_FD_READ) {
/* Nonblocking mode. */
if (THIS->buf.s->len >= (ptrdiff_t)sizeof(struct inotify_event)) {
/* There's stuff waiting in the buffer, so schedule
* an immediate call_out of poll() to handle the data.
*/
ref_push_function(Pike_fp->current_object,
f_Inotify_cq__Instance_poll_fun_num +
Pike_fp->context->identifier_level);
push_int(0);
safe_apply(get_backend_obj(THIS->box.backend), "call_out", 2);
pop_stack();
}
}
}
/*! @decl int add_watch(string file, int mask)
*! Add a watch for a certain file or directory and specific events.
*! Adding more than one watch for one file will overwrite the
......@@ -275,6 +293,9 @@ PIKECLASS _Instance {
MKPCHARP("\0\0\0\0\0\0\0\0", 0), 8, 0);
}
closedir(dir);
/* Wake up the backend if we've added stuff to the buffer. */
check_schedule_poll();
}
}
RETURN wd;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment