1
mirror of https://github.com/rapid7/metasploit-framework synced 2024-11-05 14:57:30 +01:00

break out of the main loop when we get eof (or any other area) on the main socket. fixes infinite loop in the server when client exits

git-svn-id: file:///home/svn/framework3/trunk@9402 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
James Lee 2010-06-03 00:24:55 +00:00
parent 9dc298f56d
commit e4e2bc61a4

View File

@ -901,7 +901,7 @@ if ($listen) {
$ipaddr = '127.0.0.1';
$msgsock=socket_create(AF_INET,SOCK_STREAM,SOL_TCP);
$res = socket_connect($msgsock,$ipaddr,$port);
log($res);
my_print($res);
if (!$res) {
die();
}
@ -914,10 +914,12 @@ $file_readers = array();
# Main dispatch loop
#
while (FALSE !== socket_select($r=$socket_readers, $w=NULL, $e=NULL, 1)) {
$read_failed = false;
foreach ($r as $ready) {
if ($ready == $msgsock) {
$request = socket_read($msgsock, 8, PHP_BINARY_READ);
if (FALSE==$request) {
$read_failed = true;
break;
}
$a = unpack("Nlen/Ntype", $request);
@ -941,6 +943,9 @@ while (FALSE !== socket_select($r=$socket_readers, $w=NULL, $e=NULL, 1)) {
}
}
}
if ($read_failed) {
break;
}
#if (0 < count($file_readers)) {
# stream_select($r=$file_readers, $w=NULL, $e=NULL, 0);
# foreach ($r as $ready) {