Skip to content

Commit

Permalink
Various bugfixes in network i/o.
Browse files Browse the repository at this point in the history
  • Loading branch information
kakserpom committed Oct 7, 2012
1 parent 2008b68 commit e4848a4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/ConnectionPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -498,12 +498,12 @@ public function onAcceptEvent($stream, $events, $arg) {
if ($this->allowedClients !== null) {
$conn->ready = false; // lockwait
}
$conn->onWriteOnce($handler);
$conn->onWriteOnce($getpeername);
return;
}
}
$conn->addr = $host;
$conn->port = $port;
$conn->port = $port;
if ($conn->pool->allowedClients !== null) {
if (!ConnectionPool::netMatch($conn->pool->allowedClients, $host)) {
Daemon::log('Connection is not allowed (' . $host . ')');
Expand Down
13 changes: 10 additions & 3 deletions lib/IOStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ abstract class IOStream {
public $onWriteOnce;
public $timeout = null;
public $url;
public $alive = false; // alive?
public function touchEvent() {
if ($this->timeout !== null) {
Expand Down Expand Up @@ -244,6 +245,10 @@ public function onWrite() { }
* @return boolean Success.
*/
public function write($s) {
if (!$this->alive) {
Daemon::log('Attempt to write to dead IOStream ('.get_class($this).')');
return false;
}
if (!$this->buffer) {
return false;
}
Expand Down Expand Up @@ -341,6 +346,7 @@ public function close() {

public function closeFd() {
fclose($this->fd);
$this->closed = true;
}

/**
Expand Down Expand Up @@ -397,10 +403,11 @@ public function onWriteEvent($stream, $arg = null) {
$this->ready = true;
while (!$this->onWriteOnce->isEmpty()) {
call_user_func($this->onWriteOnce->pop(), $this);
if (!$this->ready) {
return;
}
}
if (!$this->ready) {
return;
}
$this->alive = true;
$this->onReady();
} else {
while (!$this->onWriteOnce->isEmpty()) {
Expand Down
4 changes: 2 additions & 2 deletions lib/IPCManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ public function onPacket($p) {
$self = Daemon::$process;

if (Daemon::supported(Daemon::SUPPORT_RUNKIT_IMPORT)) {
//Daemon::log('--start runkit_import('.$path.')');
Daemon::log('--start runkit_import('.$path.')');
runkit_import($path, RUNKIT_IMPORT_FUNCTIONS | RUNKIT_IMPORT_CLASSES | RUNKIT_IMPORT_OVERRIDE);
//Daemon::log('--end runkit_import('.$path.')');
Daemon::log('--end runkit_import('.$path.')');
} else {
$this->appInstance->log('Cannot import \''.$path.'\': runkit_import is not callable.');
}
Expand Down

0 comments on commit e4848a4

Please sign in to comment.