Permalink
Browse files

Fix stomp_read_frame when buffered

  • Loading branch information...
1 parent ce37472 commit 5f7d260c05beed5dc8ebead24b045ef46d9a36ed @adoy adoy committed Nov 19, 2012
Showing with 9 additions and 2 deletions.
  1. +1 −0 package.xml
  2. +8 −2 stomp.c
View
@@ -17,6 +17,7 @@ This extension allows php applications to communicate with any Stomp compliant M
<stability><release>stable</release><api>stable</api></stability>
<license uri="http://www.php.net/license">PHP License</license>
<notes>
+- Fix stomp_read_frame when buffered (Pierrick)
</notes>
<contents>
<dir name="/">
View
10 stomp.c
@@ -553,14 +553,20 @@ stomp_frame_t *stomp_read_frame(stomp_t *stomp)
/* Check for the content length */
if (zend_hash_find(f->headers, "content-length", sizeof("content-length"), (void **)&length_str) == SUCCESS) {
+ int recv = 0;
char endbuffer[2];
length = 2;
f->body_length = atoi(length_str);
f->body = (char *) emalloc(f->body_length);
- if (-1 == stomp_recv(stomp, f->body, f->body_length)) {
- RETURN_READ_FRAME_FAIL;
+ while (recv != f->body_length) {
+ int l = stomp_recv(stomp, f->body + recv, f->body_length - recv);
+ if (-1 == l) {
+ RETURN_READ_FRAME_FAIL;
+ } else {
+ recv += l;
+ }
}
if (length != stomp_recv(stomp, endbuffer, length) || endbuffer[0] != '\0' || endbuffer[1] != '\n') {

0 comments on commit 5f7d260

Please sign in to comment.