From 4742fac8f9b9769a79d8a66ac423406e7a43cace Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sun, 5 Jul 2015 23:08:10 -0600 Subject: [PATCH] Adjustments to event_socket_request to make it faster. --- resources/switch.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/resources/switch.php b/resources/switch.php index 1919eb77c0..2c6b46d89d 100644 --- a/resources/switch.php +++ b/resources/switch.php @@ -322,9 +322,7 @@ function event_socket_request($fp, $cmd) { } fputs($fp, "\n"); //second line feed to end the headers - usleep(100); //allow time for reponse - - $response = ""; + $response = ''; $i = 0; $content_length = 0; while (!feof($fp)) { @@ -342,17 +340,16 @@ function event_socket_request($fp, $cmd) { } } - usleep(50); //allow time for reponse - - //prevent an endless loop //optional because of script timeout - if ($i > 30000) { break; } - if ($content_length > 0) { //is content_length set //stop reading if all content has been read. if (strlen($response) >= $content_length) { break; } } + else { + //prevent an endless loop + if ($i > 300000) { break; } + } $i++; } @@ -364,6 +361,8 @@ function event_socket_request($fp, $cmd) { } + + function event_socket_request_cmd($cmd) { global $db, $domain_uuid, $host;