-
Notifications
You must be signed in to change notification settings - Fork 119
/
bug_gh_59_2.phpt
55 lines (43 loc) · 982 Bytes
/
bug_gh_59_2.phpt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
--TEST--
Test for Github issue #59
--SKIPIF--
<?php
require_once(dirname(__FILE__) . '/skipif.inc');
if (!extension_loaded ('pcntl'))
die("skip");
?>
--FILE--
<?php
function forkRepWorker()
{
$pid = pcntl_fork();
if ($pid != 0) {
return $pid;
}
$context = new ZMQContext();
$rep = $context->getSocket(\ZMQ::SOCKET_REP);
$rep->connect('ipc://test2.ipc');
$msg = $rep->recv();
$rep->send($msg.'bar');
sleep(2);
exit;
}
$context = new ZMQContext(1, false);
$dealer = $context->getSocket(ZMQ::SOCKET_DEALER);
$pids[] = forkRepWorker($dealer);
$pids[] = forkRepWorker($dealer);
$dealer->bind('ipc://test2.ipc');
sleep (1);
$dealer->sendmulti(array('A', '', 'foo'));
$dealer->sendmulti(array('B', '', 'bar'));
$msgs = array();
$msgs[] = $dealer->recvmulti();
$msgs[] = $dealer->recvmulti();
foreach ($pids as $pid) {
pcntl_waitpid($pid, $status, WUNTRACED);
}
var_dump(count ($msgs));
echo "OK";
--EXPECT--
int(2)
OK