pike.git / src / modules / Inotify / inotify.cmod

version» Context lines:

pike.git/src/modules/Inotify/inotify.cmod:188:    Pike_compiler->new_program,    SEE_PROTECTED|SEE_PRIVATE);    if (event_callback_fun_num == -1) {    Pike_fatal("Inotify: Event callback variable not mapped!\n");    }    /* We don't want to count references to ourselves. */    ID_FROM_INT(Pike_compiler->new_program, event_callback_fun_num)->    identifier_flags |= IDENTIFIER_NO_THIS_REF;    }    +  static void check_schedule_poll(void); +     /*! @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    *! previous watch unless @[System.Inotify.IN_MASK_ADD] is contained    *! in the mask.    *! @param path    *! Path of the file or directory.    *! @param mask    *! Integer mask specifying the event type. This can be a    *! combination of different event types using bitwise OR.
pike.git/src/modules/Inotify/inotify.cmod:271:       string_build_mkspace(&THIS->buf, sizeof(ev) + ev.len, 0);    string_builder_binary_strcat0(&THIS->buf,    (p_wchar0 *)&ev,    sizeof(ev));    string_builder_strcat(&THIS->buf, dirent->d_name);    string_builder_fill(&THIS->buf, pad+1,    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;    }          /*! @decl int query_fd()    *! @returns    *! Returns the file descriptor associated with this inotify instance.    */
pike.git/src/modules/Inotify/inotify.cmod:458:    }    } while (bytes > 0);    if (off) {    /* Unlikely, but... */    THIS->buf.s->len -= off;    memmove(THIS->buf.s->str, THIS->buf.s->str + off,    THIS->buf.s->len);    }    }    +  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(); +  } +  } +  } +     static int got_inotify_event(struct fd_callback_box *box, int UNUSED(event))    {    apply(box->ref_obj, "poll", 0);    pop_stack();    return 0;    }       INIT {    THIS->box.fd = -1;    init_string_builder_alloc(&THIS->buf, 1024, 0);