Skip to content

Commit

Permalink
Fix to consume loop to prevent passing empty statuses to enqueueStatu…
Browse files Browse the repository at this point in the history
…s(), which was happening occasionally when for some reason the buffer would hold two "\r\n\r\n" sequences.
  • Loading branch information
thaddeusmt committed Jan 15, 2014
1 parent 4d2df59 commit 92026de
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/Phirehose.php
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,10 @@ public function consume($reconnect = TRUE)
//Process each full tweet inside $this->buff
while(1){
$eol = strpos($this->buff,"\r\n"); //Find next line ending
if($eol===0) { // if 0, then buffer starts with "\r\n", so trim it and loop again
$this->buff = substr($this->buff,$eol+2); // remove the "\r\n" from line start
continue; // loop again
}
if($eol===false)break; //Time to get more data
$enqueueStart = microtime(TRUE);
$this->enqueueStatus(substr($this->buff,0,$eol));
Expand Down

1 comment on commit 92026de

@az2012
Copy link

@az2012 az2012 commented on 92026de Jan 18, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haved signaled this problem to Adam a week ago and also I have patched the library, but now I came back your official library.
I test it again and hope works! Thanks for your grat job!

Please sign in to comment.