public function addWatch($path, $subscriber, $flags = NULL) { $path = realpath($path); if (!isset($this->files[$path])) { $this->files[$path] = array(); if ($this->inotify) { $this->descriptors[inotify_add_watch($this->inotify, $path, $flags ?: IN_MODIFY)] = $path; } } $this->files[$path][] = $subscriber; Daemon_TimedEvent::setTimeout('fileWatcherTimedEvent'); return true; }
/** * Called when the connection has got new data * @param resource Descriptor * @param mixed Attacted variable * @return void */ public function onReadEvent($stream, $arg) { $connId = is_array($arg) ? $arg[0] : array_search($stream, Daemon::$process->pool, TRUE); if (Daemon::$config->logevents->value) { Daemon::$process->log(get_class($this) . '::' . __METHOD__ . '(' . $connId . ') invoked. ' . Debug::dump(Daemon::$process->pool[$connId])); } if ($this->queuedReads) { Daemon::$process->readPoolState[$connId] = TRUE; Daemon_TimedEvent::setTimeout('readPoolEvent'); } $success = FALSE; if (isset($this->sessions[$connId])) { if ($this->sessions[$connId]->readLocked) { return; } while (($buf = $this->read($connId, $this->readPacketSize)) !== FALSE) { $success = TRUE; $this->sessions[$connId]->stdin($buf); } } }