Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

bug fix for Stomp::readFrame, was occasionally reading more than one Frame #22

Merged
merged 1 commit into from

2 participants

@boonedox

fread reads up to specified number of bytes or EOF.
fgets reads up to "\n", number of bytes or EOF.

The problem with fread is that if there is more than one Frame
on the socket, it will read the current Frame and part of the next
Frame.  Stomp::readFrame() is expected to just read the next Frame.

@boonedox boonedox use fgets instead of fread in Stomp::readFrame()
fread reads up to specified number of bytes or EOF.
fgets reads up to "\n", number of bytes or EOF.

The problem with fread is that if there is more than one Frame
on the socket, it will read the current Frame and part of the next
Frame.  Stomp::readFrame() is expected to just read the next Frame.
e143d5c
@monofone monofone merged commit 4ac51c0 into dejanb:master
@monofone
Collaborator

Thanks for your Help

@jmglsn jmglsn referenced this pull request from a commit in stomp-php/stomp-php
@jmglsn jmglsn Read until first EOL instead of full 1024 bytes. fixes dejanb/stomp-p…
…hp#22

The deleted test case seems to check for a unwanted behavior. The client might acted too greedy, buffering frames.
5f74d45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 20, 2013
  1. @boonedox

    use fgets instead of fread in Stomp::readFrame()

    boonedox authored
    fread reads up to specified number of bytes or EOF.
    fgets reads up to "\n", number of bytes or EOF.
    
    The problem with fread is that if there is more than one Frame
    on the socket, it will read the current Frame and part of the next
    Frame.  Stomp::readFrame() is expected to just read the next Frame.
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  src/FuseSource/Stomp/Stomp.php
View
2  src/FuseSource/Stomp/Stomp.php
@@ -563,7 +563,7 @@ public function readFrame ()
$end = false;
do {
- $read = fread($this->_socket, $rb);
+ $read = fgets($this->_socket, $rb);
if ($read === false || $read === "") {
$this->_reconnect();
return $this->readFrame();
Something went wrong with that request. Please try again.