Fix stomp_read_frame when buffered

v1.1
Pierrick Charron 2012-11-18 19:23:27 -05:00
parent ce374724b9
commit 5f7d260c05
2 changed files with 9 additions and 2 deletions

View File

@ -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="/">

10
stomp.c
View File

@ -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') {