Skip to content

Commit fa715be

Browse files
committed
Fixed dispatch error
1 parent 8c1fc2c commit fa715be

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
<?php
22
$serv = new swoole_server("127.0.0.1", 9501);
33
$serv->set(array(
4-
'open_length_check' => 1,
5-
'worker_num' => 1,
6-
'package_length_type' => 's',
7-
'package_length_offset' => 2, //第几个字节开始表示长度
8-
'package_body_offset' => 4, //第几个字节开始计算长度
9-
'package_max_length' => 2000, //协议最大长度
4+
'open_length_check' => 1,
5+
'worker_num' => 1,
6+
'package_length_type' => 's',
7+
'package_length_offset' => 2, //第N个字节是包长度的值
8+
'package_body_offset' => 4, //第几个字节开始计算长度
9+
'package_max_length' => 2000, //协议最大长度
1010
));
1111
$serv->on('connect', function ($serv, $fd){
12-
echo "Client:Connect.\n";
12+
echo "Client:Connect.\n";
1313
});
1414
$serv->on('receive', function ($serv, $fd, $from_id, $data) {
15-
$protocol = unpack('s*', $data);
16-
$output = '>> ';
17-
foreach ($protocol as $k=>$v) {
18-
$output .= sprintf('%d,', $v);
19-
}
20-
echo $output . "\n";
21-
//$serv->send($fd, 'Swoole: '.$data);
22-
//$serv->close($fd);
15+
$protocol = unpack('s*', $data);
16+
$output = '>> ';
17+
foreach ($protocol as $k=>$v) {
18+
$output .= sprintf('%d,', $v);
19+
}
20+
echo $output . "\n";
21+
//$serv->send($fd, 'Swoole: '.$data);
22+
//$serv->close($fd);
2323
});
2424
$serv->on('close', function ($serv, $fd) {
25-
echo "Client: Close.\n";
25+
echo "Client: Close.\n";
2626
});
2727
$serv->start();

src/network/Connection.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ SWINLINE int swConnection_send_string_buffer(swConnection *conn)
360360
/**
361361
* unlock
362362
*/
363-
SwooleTG.factory_target_worker = 0;
363+
SwooleTG.factory_target_worker = -1;
364364
SwooleTG.factory_lock_target = 0;
365365

366366
#endif

0 commit comments

Comments
 (0)