diff options
author | Simon Rettberg | 2016-12-01 15:18:28 +0100 |
---|---|---|
committer | Simon Rettberg | 2016-12-01 15:18:28 +0100 |
commit | cf8426315d7ea37fab06fb65bc1160822384b5a3 (patch) | |
tree | d9907981698c4eb11e781cb1f5b2b94c35e815a0 /inc/taskmanager.inc.php | |
parent | [locations] Also make sure the opened location is in view (diff) | |
download | slx-admin-cf8426315d7ea37fab06fb65bc1160822384b5a3.tar.gz slx-admin-cf8426315d7ea37fab06fb65bc1160822384b5a3.tar.xz slx-admin-cf8426315d7ea37fab06fb65bc1160822384b5a3.zip |
[Taskmanager] Add support for compressed replies
Diffstat (limited to 'inc/taskmanager.inc.php')
-rw-r--r-- | inc/taskmanager.inc.php | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/inc/taskmanager.inc.php b/inc/taskmanager.inc.php index c82d2b1a..bd60e8ae 100644 --- a/inc/taskmanager.inc.php +++ b/inc/taskmanager.inc.php @@ -71,7 +71,7 @@ class Taskmanager return false; self::init(); $seq = (string) mt_rand(); - $message = "$seq, status, $task"; + $message = "$seq, status, $task"; $sent = socket_send(self::$sock, $message, strlen($message), 0); $reply = self::readReply($seq); if (!is_array($reply)) @@ -210,7 +210,22 @@ class Taskmanager $tries = 0; while (($bytes = socket_recvfrom(self::$sock, $buf, 90000, 0, $bla1, $bla2)) !== false || socket_last_error() === 11) { $parts = explode(',', $buf, 2); - if (count($parts) == 2 && $parts[0] == $seq) { + // Do we have compressed data? + if (substr($parts[0], 0, 3) === '+z:') { + $parts[0] = substr($parts[0], 3); + $gz = true; + } else { + $gz = false; + } + // See if it's our message + if (count($parts) === 2 && $parts[0] === $seq) { + if ($gz) { + $parts[1] = gzinflate($parts[1]); + if ($parts[1] === false) { + error_log('Taskmanager: Invalid deflate data received'); + continue; + } + } return json_decode($parts[1], true); } if (++$tries > 10) |