Skip to content

Commit 92026de

Browse files
committed
Fix to consume loop to prevent passing empty statuses to enqueueStatus(), which was happening occasionally when for some reason the buffer would hold two "\r\n\r\n" sequences.
1 parent 4d2df59 commit 92026de

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/Phirehose.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,10 @@ public function consume($reconnect = TRUE)
464464
//Process each full tweet inside $this->buff
465465
while(1){
466466
$eol = strpos($this->buff,"\r\n"); //Find next line ending
467+
if($eol===0) { // if 0, then buffer starts with "\r\n", so trim it and loop again
468+
$this->buff = substr($this->buff,$eol+2); // remove the "\r\n" from line start
469+
continue; // loop again
470+
}
467471
if($eol===false)break; //Time to get more data
468472
$enqueueStart = microtime(TRUE);
469473
$this->enqueueStatus(substr($this->buff,0,$eol));

0 commit comments

Comments
 (0)