Browse Source

Some more debug

pull/551/head
Timothée Jaussoin 8 years ago
parent
commit
2360169aa1
  1. 2
      composer.json
  2. 20
      composer.lock
  3. 2
      linker.php
  4. 9
      src/Movim/Daemon/Core.php
  5. 53
      src/Movim/Daemon/Session.php

2
composer.json

@ -24,7 +24,7 @@
"cboden/ratchet": "^0.4.0",
"react/http": "dev-master#cd15204bd15d106d7832c680e4fb0ca0ce2f5e30",
"react/zmq": "dev-master#3926b258de0d6e31b15087b926bf2baf2e9540a2",
"react/zmq": "dev-master",
"respect/validation": "^1.1",
"ezyang/htmlpurifier": "^4.9",

20
composer.lock

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "8f6bbcf02849cf7bc83e928dc608386a",
"content-hash": "3a87904a3cb5a2679671575c4d9e274d",
"packages": [
{
"name": "cboden/ratchet",
@ -362,12 +362,12 @@
"source": {
"type": "git",
"url": "https://github.com/oscarotero/Embed.git",
"reference": "f951eb15872b05fef056f48442efef2dbb5d51ed"
"reference": "b8bb0ca7115dec0b73f311f0866d6b20b41b040a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/oscarotero/Embed/zipball/f951eb15872b05fef056f48442efef2dbb5d51ed",
"reference": "f951eb15872b05fef056f48442efef2dbb5d51ed",
"url": "https://api.github.com/repos/oscarotero/Embed/zipball/b8bb0ca7115dec0b73f311f0866d6b20b41b040a",
"reference": "b8bb0ca7115dec0b73f311f0866d6b20b41b040a",
"shasum": ""
},
"require": {
@ -407,7 +407,7 @@
"opengraph",
"twitter cards"
],
"time": "2017-09-25 20:57:58"
"time": "2017-11-06 20:30:55"
},
{
"name": "evenement/evenement",
@ -1735,19 +1735,19 @@
"source": {
"type": "git",
"url": "https://github.com/reactphp/zmq.git",
"reference": "3926b258de0d6e31b15087b926bf2baf2e9540a2"
"reference": "85eb278e1303f27a4538580c95ce3453a751b23f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/reactphp/zmq/zipball/3926b258de0d6e31b15087b926bf2baf2e9540a2",
"reference": "3926b258de0d6e31b15087b926bf2baf2e9540a2",
"url": "https://api.github.com/repos/reactphp/zmq/zipball/85eb278e1303f27a4538580c95ce3453a751b23f",
"reference": "85eb278e1303f27a4538580c95ce3453a751b23f",
"shasum": ""
},
"require": {
"evenement/evenement": "^3.0 || ^2.0",
"ext-zmq": "*",
"php": ">=5.4.0",
"react/event-loop": "0.4.*"
"react/event-loop": "^1.0 || ^0.5 || ^0.4"
},
"require-dev": {
"ext-pcntl": "*",
@ -1768,7 +1768,7 @@
"zeromq",
"zmq"
],
"time": "2017-09-30 22:09:26"
"time": "2017-11-08 07:15:45"
},
{
"name": "respect/validation",

2
linker.php

@ -50,7 +50,7 @@ $loop->addPeriodicTimer(5, function() use(&$conn, &$timestamp) {
}
});
$zmq = new \React\ZMQ\Context($loop);
$zmq = new \React\ZMQ\Context($loop, new \ZMQContext(2, false));
$file = CACHE_PATH . 'movim_feeds_' . getenv('sid') . '.ipc';
$pullSocket = $zmq->getSocket(ZMQ::SOCKET_PUSH);

9
src/Movim/Daemon/Core.php

@ -15,7 +15,10 @@ class Core implements MessageComponentInterface
public $loop;
public $baseuri;
public $context;
public $pullContext;
public $pushContext;
public $single = ['visio'];
public $singlelocks = [];
@ -28,8 +31,11 @@ class Core implements MessageComponentInterface
$this->loop = $loop;
$this->baseuri = $baseuri;
echo 'before context ' . shell_exec('ls /proc/'.getmypid().'/fd | wc -l');
$this->context = new \React\ZMQ\Context($loop, new \ZMQContext(2, false));
echo 'after context ' . shell_exec('ls /proc/'.getmypid().'/fd | wc -l');
(new \Modl\SessionxDAO)->clear();
$this->cleanupIPCs();
@ -102,6 +108,7 @@ class Core implements MessageComponentInterface
if (!array_key_exists($sid, $this->sessions)) {
$language = $this->getLanguage($conn);
$offset = $this->getOffset($conn);
$this->sessions[$sid] = new Session(
$this->loop,
$sid,

53
src/Movim/Daemon/Session.php

@ -18,7 +18,6 @@ class Session
public $registered;
public $started;
protected $buffer;
private $state;
private $verbose;
@ -29,8 +28,8 @@ class Session
private $language;
private $offset;
public function __construct($loop, $sid, $context, $baseuri, $language = false,
$offset = 0, $verbose = false, $debug = false)
public function __construct($loop, $sid, $context, $baseuri,
$language = false, $offset = 0, $verbose = false, $debug = false)
{
$this->sid = $sid;
$this->baseuri = $baseuri;
@ -40,10 +39,8 @@ class Session
$this->verbose = $verbose;
$this->debug = $debug;
$this->context = $context;
$this->clients = new \SplObjectStorage;
$this->register($loop, $this);
$this->register($loop, $this, $context);
$this->timestamp = time();
}
@ -84,21 +81,22 @@ class Session
return $this->clients->count();
}
private function register($loop, $me)
private function register($loop, $me, $context)
{
$buffer = '';
echo 'begin ' . shell_exec('ls /proc/'.getmypid().'/fd | wc -l');
$this->pullSocket = $context->getSocket(\ZMQ::SOCKET_PULL);
$this->pushSocket = $context->getSocket(\ZMQ::SOCKET_PUSH);
// Communication sockets with the linker
$file = CACHE_PATH . 'movim_feeds_' . $this->sid . '.ipc';
$this->pullSocket = $this->context->getSocket(\ZMQ::SOCKET_PULL);
$this->pullSocket->getWrappedSocket()->setSockOpt(\ZMQ::SOCKOPT_LINGER, 0);
echo 'pull ' . shell_exec('ls /proc/'.getmypid().'/fd | wc -l');
//$this->pullSocket->getWrappedSocket()->setSockOpt(\ZMQ::SOCKOPT_LINGER, 0);
$this->pullSocket->bind('ipc://' . $file . '_pull', true);
$this->pushSocket = $this->context->getSocket(\ZMQ::SOCKET_PUSH);
$this->pushSocket->getWrappedSocket()->setSockOpt(\ZMQ::SOCKOPT_LINGER, 0);
var_dump(get_class($this->pullSocket));
echo 'push ' . shell_exec('ls /proc/'.getmypid().'/fd | wc -l');
//$this->pushSocket->getWrappedSocket()->setSockOpt(\ZMQ::SOCKOPT_LINGER, 0);
$this->pushSocket->bind('ipc://' . $file . '_push', true);
echo 'pushbind ' . shell_exec('ls /proc/'.getmypid().'/fd | wc -l');
$this->pullSocket->on('message', function($msg) use ($me) {
$me->messageOut($msg);
});
@ -117,21 +115,28 @@ class Session
]
);
$this->process->start($loop);
echo 'al ' . shell_exec('ls /proc/'.getmypid().'/fd | wc -l');
// The linker died, we close properly the session
$this->process->on('exit', function($output) use ($me, $file) {
$this->process->on('exit', function($output) use ($me, $file, $context) {
if ($me->verbose) {
echo colorize($this->sid, 'yellow'). " : ".colorize("linker killed \n", 'red');
}
echo 'process end ' . shell_exec('ls /proc/'.getmypid().'/fd | wc -l');
$me->process = null;
$me->closeAll();
$this->pullSocket->unbind('ipc://' . $file . '_pull');
$this->pushSocket->unbind('ipc://' . $file . '_push');
$this->pullSocket->close();
$this->pushSocket->close();
echo 'process clean ' . shell_exec('ls /proc/'.getmypid().'/fd | wc -l');
$me->pullSocket->unbind('ipc://' . $file . '_pull');
echo 'pull unbind ' . shell_exec('ls /proc/'.getmypid().'/fd | wc -l');
$me->pushSocket->unbind('ipc://' . $file . '_push');
echo 'push unbind ' . shell_exec('ls /proc/'.getmypid().'/fd | wc -l');
$me->pullSocket->close();
echo 'pull close ' . shell_exec('ls /proc/'.getmypid().'/fd | wc -l');
$me->pushSocket->close();
echo 'push close ' . shell_exec('ls /proc/'.getmypid().'/fd | wc -l');
unset($me->pullSocket);
unset($me->pushSocket);
unset($context);
echo 'end ' . shell_exec('ls /proc/'.getmypid().'/fd | wc -l');
(new \Modl\PresenceDAO)->clearPresence();
(new \Modl\SessionxDAO)->delete($this->sid);

Loading…
Cancel
Save