function ev_error($buffer, $error, $id) { event_buffer_disable(self::$buffers[$id], EV_READ | EV_WRITE); event_buffer_free(self::$buffers[$id]); fclose(self::$connections[$id]); unset(self::$buffers[$id], self::$connections[$id]); }
function ev_error($buffer, $error, $id) { event_buffer_disable($GLOBALS['buffers'][$id], EV_READ | EV_WRITE); event_buffer_free($GLOBALS['buffers'][$id]); fclose($GLOBALS['connections'][$id]); unset($GLOBALS['buffers'][$id], $GLOBALS['connections'][$id]); }
function ev_error($buffer, $error, $id) { $this->send_to_all(json_encode(array('type' => 'closed', 'id' => $id))); event_buffer_disable(self::$buffers[$id], EV_READ | EV_WRITE); event_buffer_free(self::$buffers[$id]); fclose(self::$connections[$id]); unset(self::$buffers[$id], self::$connections[$id], self::$users[$id]); }
/** * Free from loop */ public function __destruct() { if (!empty($this->event)) { event_buffer_disable($this->event, EV_READ | EV_WRITE); event_buffer_free($this->event); unset($this->stream, $this->event); } }
protected function Close($id) { event_buffer_disable($this->buffers[$id], EV_READ | EV_WRITE); event_buffer_free($this->buffers[$id]); fclose($this->connections[$id]); unset($this->buffers[$id], $this->connections[$id]); $this->onClose($id); }
public function disconnectClient($id) { $this->log("disconnectClient({$id})"); $client = $this->clients[$id]; if (!$client['request']->fired('end')) { $client['request']->fire('end'); } if (!$client['disconnect'] && !$client['request']->fired('close')) { $client['request']->fire('close', $id); } /// $this->clients[$id]['response']->connection = null; $this->clients[$id]['response']->ev_buffer = null; /// stream_socket_shutdown($client['socket'], STREAM_SHUT_RDWR); event_buffer_disable($client['buffer'], EV_READ | EV_WRITE); event_buffer_free($client['buffer']); unset($this->clients[$id]); }
/** * Close the connection * @param integer Connection's ID * @return void */ public function closeConnection($connId) { if (Daemon::$config->logevents->value) { Daemon::$process->log('closeConnection(' . $connId . ').'); } if (!isset($this->buf[$connId])) { return; } if (isset($this->readEvents[$connId])) { event_del($this->readEvents[$connId]); event_free($this->readEvents[$connId]); unset($this->readEvents[$connId]); } event_buffer_free($this->buf[$connId]); if (isset(Daemon::$process->pool[$connId])) { if (Daemon::$useSockets) { socket_close(Daemon::$process->pool[$connId]); } else { fclose(Daemon::$process->pool[$connId]); } } unset(Daemon::$process->pool[$connId]); unset(Daemon::$process->poolApp[$connId]); unset(Daemon::$process->readPoolState[$connId]); unset($this->buf[$connId]); unset($this->poolQueue[$connId]); unset($this->poolState[$connId]); unset(Daemon::$process->poolState[$connId]); }
/** * Frees the event, cleans up resources * * @return void */ public function free() { if (is_null($this->resource)) { return null; } event_buffer_free($this->resource); $this->resource = null; }
public function removeClient(Client $client) { if ($this->disconnect_callback) { call_user_func_array($this->disconnect_callback, [$client]); } $buf = $client->getBuffer(); $conn = $client->getConnection(); event_buffer_disable($buf, EV_READ | EV_WRITE); event_buffer_free($buf); fclose($conn); }
/** * Zamkniecie polaczenia * @return boolean czy zamknieto polaczenie */ public function close() { if (is_resource($this->eventBuffer) and 'buffer event' == get_resource_type($this->eventBuffer)) { event_buffer_disable($this->eventBuffer, EV_READ | EV_WRITE); event_buffer_free($this->eventBuffer); } if (is_resource($this->sock)) { fclose($this->sock); } return true; }
protected function close($connectionId) { fclose($this->getConnectionById($connectionId)); if (isset($this->clients[$connectionId])) { unset($this->clients[$connectionId]); } elseif (isset($this->_services[$connectionId])) { unset($this->_services[$connectionId]); if (!$this->_services) { exit; } } elseif ($this->getConnectionById($connectionId) == $this->_server) { /*unset($this->_server); event_del($this->event); event_free($this->event); exit();*/ } unset($this->_write[$connectionId]); unset($this->_read[$connectionId]); event_buffer_disable($this->buffers[$connectionId], EV_READ | EV_WRITE); event_buffer_free($this->buffers[$connectionId]); unset($this->buffers[$connectionId]); }
protected function close($connectionId) { fclose($this->getConnectionById($connectionId)); if (isset($this->clients[$connectionId])) { unset($this->clients[$connectionId]); } elseif (isset($this->services[$connectionId])) { unset($this->services[$connectionId]); } elseif ($this->getIdByConnection($this->_server) == $connectionId) { unset($this->_server); /*event_del($this->event); event_free($this->event); unset($this->event);*/ } elseif ($this->getIdByConnection($this->_service) == $connectionId) { unset($this->_service); /*event_del($this->service_event); event_free($this->service_event); unset($this->service_event);*/ } elseif ($this->getIdByConnection($this->_master) == $connectionId) { unset($this->_master); } unset($this->_write[$connectionId]); unset($this->_read[$connectionId]); event_buffer_disable($this->buffers[$connectionId], EV_READ | EV_WRITE | EV_PERSIST); event_buffer_free($this->buffers[$connectionId]); unset($this->buffers[$connectionId]); }
/** * Destroys the buffered event and frees all the resources associated. * * @link http://www.php.net/manual/function.event-buffer-free.php * @see event_buffer_free * * @param bool $baseCall Argument for prevent infinite loop * * @throws EventException * * @return EventBuffer */ public function free($baseCall = false) { if ($this->check()) { event_buffer_free($this->resource); $this->resource = null; if (false === $baseCall) { $this->base->removeEvent($this->name); } $this->base = null; $this->arguments = array(); } return $this; }
protected function freeBuffer($conn_num) { event_buffer_disable($this->connection_buffers[$conn_num], EV_READ | EV_WRITE); event_buffer_free($this->connection_buffers[$conn_num]); unset($this->connection_buffers[$conn_num]); self::log('Connection', $conn_num, 'buffer is free. Fly, bird, fly!'); }
public function Shutdown($SendFin = true, $Force = false) { if ($this->isInit() && !$Force) { $this->Server->ClientDisconnected($this); } event_del($this->BufferEvent); event_buffer_free($this->BufferEvent); if ($SendFin) { fwrite($this->Socket, self::ChunkDataFin); } $this->Remove(); // echo "Client $this disconnect.\n"; @stream_socket_shutdown($this->Socket, STREAM_SHUT_RDWR); @fclose($this->Socket); $this->Server->DecCurrentConnected(); }
function ev_write($buffer, $id) { global $clients; // close if the client is on the kill list if (!empty($clients[$id]['kill_time'])) { event_buffer_disable($clients[$id]['ev_buffer'], EV_READ | EV_WRITE); event_buffer_free($clients[$id]['ev_buffer']); fclose($clients[$id]['socket']); unset($clients[$id]); } }
function _closeConnections() { if (APP_DEBUG === true) { Log::write('eSeal offline. 电子铅封退出。', Log::INFO); } foreach (self::$buffers as $key => $buf) { event_buffer_disable($buf, EV_READ | EV_WRITE); event_buffer_free($buf); unset(self::$buffers[$key]); } foreach (self::$connections as $key => $conn) { fclose($conn); unset(self::$connections[$key]); } event_base_loopexit(self::$base); event_base_free(self::$base); fclose(self::$socket_server); }
protected function close($connectionId) { @fclose($this->getConnectionById($connectionId)); event_buffer_disable($this->buffers[$connectionId], EV_READ | EV_WRITE | EV_PERSIST); event_buffer_free($this->buffers[$connectionId]); unset($this->buffers[$connectionId]); }
public function closeConnection($connId) { if (Daemon::$settings['logevents']) { Daemon::log('[WORKER ' . Daemon::$worker->pid . '] closeConnection(' . $connId . ').'); } if (!isset($this->buf[$connId])) { return; } if (isset($this->readEvents[$connId])) { event_del($this->readEvents[$connId]); event_free($this->readEvents[$connId]); unset($this->readEvents[$connId]); } event_buffer_free($this->buf[$connId]); if (Daemon::$useSockets) { socket_close(Daemon::$worker->pool[$connId]); } else { fclose(Daemon::$worker->pool[$connId]); } unset(Daemon::$worker->pool[$connId]); unset(Daemon::$worker->poolApp[$connId]); unset(Daemon::$worker->readPoolState[$connId]); unset($this->buf[$connId]); unset($this->poolQueue[$connId]); unset(Daemon::$worker->poolState[$connId]); }
public function closeWrite() { if (is_resource($this->writeBuf)) { if (event_buffer_free($this->writeBuf) === FALSE) { $this->writeBuf = FALSE; throw new Exception('freeing write buffer failed.'); } $this->writeBuf = FALSE; } if ($this->writeFD) { fclose($this->writeFD); $this->writeFD = FALSE; } return $this; }
private function realCloseConnection($connId) { Debug::netEvent(get_class($this) . '::' . __METHOD__ . '(' . $connId . ') invoked. '); if (!isset($this->connSocketPool[$connId])) { Debug::netErrorEvent(get_class($this) . '::' . __METHOD__ . '(' . $connId . ') can not find. '); return; } stream_socket_shutdown($this->connSocketPool[$connId], STREAM_SHUT_RDWR); fclose($this->connSocketPool[$connId]); // socket_close( $this->connSocketPool[$connId] ); unset($this->connSocketPool[$connId]); event_buffer_free($this->connEvBufPool[$connId]); unset($this->connEvBufPool[$connId]); if (isset($this->connSocketSessionPool[$connId])) { $this->connSocketSessionPool[$connId]->onDestory(); unset($this->connSocketSessionPool[$connId]); } unset(daemon::$connLastContactPool[$connId]); }
private function abort_handshake($conn) { event_buffer_free($this->unauthorized[(int) $conn]); stream_socket_shutdown($conn, STREAM_SHUT_RDWR); unset($this->unauthorized[(int) $conn]); unset($this->connections[(int) $conn]); $this->clientCount--; //$this->log('clientCount', $this->clientCount); }
/** * 删除某个fd的所有事件 * @see BaseEvent::delAll() */ public function delAll($fd) { $event_key = (int) $fd; if (!empty($this->allEvents[$event_key])) { foreach ($this->allEvents[$event_key] as $flag => $event) { event_del($event); } } if (isset($this->eventBuffer[$event_key])) { event_buffer_disable($this->eventBuffer[$event_key], EV_READ | EV_WRITE); event_buffer_free($this->eventBuffer[$event_key]); } unset($this->allEvents[$event_key], $this->eventBuffer[$event_key]); return true; }
public function read_request($event, $length) { $request_message = event_buffer_read($this->offer_event, $length); event_buffer_disable($this->offer_event, EV_READ | EV_WRITE); event_buffer_free($this->offer_event); unset($this->offer_event); socket_shutdown($this->offer_socket); socket_close($this->offer_socket); unset($this->offer_socket); $this->become_intern($request_message); }
/** * Close the connection * @param integer Connection's ID * @return void */ public function close() { if (!isset($this->buffer)) { return; } if (isset($this->event)) { event_del($this->event); event_free($this->event); $this->event = null; } event_buffer_free($this->buffer); $this->buffer = null; if (isset($this->fd)) { $this->closeFd(); } }