Fix stomp_read_frame when buffered
parent
ce374724b9
commit
5f7d260c05
|
@ -17,6 +17,7 @@ This extension allows php applications to communicate with any Stomp compliant M
|
||||||
<stability><release>stable</release><api>stable</api></stability>
|
<stability><release>stable</release><api>stable</api></stability>
|
||||||
<license uri="http://www.php.net/license">PHP License</license>
|
<license uri="http://www.php.net/license">PHP License</license>
|
||||||
<notes>
|
<notes>
|
||||||
|
- Fix stomp_read_frame when buffered (Pierrick)
|
||||||
</notes>
|
</notes>
|
||||||
<contents>
|
<contents>
|
||||||
<dir name="/">
|
<dir name="/">
|
||||||
|
|
10
stomp.c
10
stomp.c
|
@ -553,14 +553,20 @@ stomp_frame_t *stomp_read_frame(stomp_t *stomp)
|
||||||
|
|
||||||
/* Check for the content length */
|
/* Check for the content length */
|
||||||
if (zend_hash_find(f->headers, "content-length", sizeof("content-length"), (void **)&length_str) == SUCCESS) {
|
if (zend_hash_find(f->headers, "content-length", sizeof("content-length"), (void **)&length_str) == SUCCESS) {
|
||||||
|
int recv = 0;
|
||||||
char endbuffer[2];
|
char endbuffer[2];
|
||||||
length = 2;
|
length = 2;
|
||||||
|
|
||||||
f->body_length = atoi(length_str);
|
f->body_length = atoi(length_str);
|
||||||
f->body = (char *) emalloc(f->body_length);
|
f->body = (char *) emalloc(f->body_length);
|
||||||
|
|
||||||
if (-1 == stomp_recv(stomp, f->body, f->body_length)) {
|
while (recv != f->body_length) {
|
||||||
RETURN_READ_FRAME_FAIL;
|
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') {
|
if (length != stomp_recv(stomp, endbuffer, length) || endbuffer[0] != '\0' || endbuffer[1] != '\n') {
|
||||||
|
|
Loading…
Reference in New Issue