Adjustments to event_socket_request to make it faster.

This commit is contained in:
markjcrane
2015-07-05 23:08:10 -06:00
parent 41f052901f
commit e522fbf8ae
+7 -8
View File
@@ -322,9 +322,7 @@ function event_socket_request($fp, $cmd) {
} }
fputs($fp, "\n"); //second line feed to end the headers fputs($fp, "\n"); //second line feed to end the headers
usleep(100); //allow time for reponse $response = '';
$response = "";
$i = 0; $i = 0;
$content_length = 0; $content_length = 0;
while (!feof($fp)) { 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 if ($content_length > 0) { //is content_length set
//stop reading if all content has been read. //stop reading if all content has been read.
if (strlen($response) >= $content_length) { if (strlen($response) >= $content_length) {
break; break;
} }
} }
else {
//prevent an endless loop
if ($i > 300000) { break; }
}
$i++; $i++;
} }
@@ -364,6 +361,8 @@ function event_socket_request($fp, $cmd) {
} }
function event_socket_request_cmd($cmd) { function event_socket_request_cmd($cmd) {
global $db, $domain_uuid, $host; global $db, $domain_uuid, $host;