Branch: Tag:

2017-06-14

2017-06-14 09:59:04 by Henrik Grubbström (Grubba) <grubba@grubba.org>

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.

192:    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:    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;