Fix bug #16930
parent
6150f2f373
commit
87b67a302d
10
php_stomp.c
10
php_stomp.c
|
@ -810,6 +810,16 @@ PHP_FUNCTION(stomp_read_frame)
|
|||
|
||||
if (stomp_select(stomp) > 0 && (res = stomp_read_frame(stomp))) {
|
||||
zval *headers = NULL;
|
||||
|
||||
if (0 == strncmp("ERROR", res->command, sizeof("ERROR") - 1)) {
|
||||
char *error_msg = NULL;
|
||||
if (zend_hash_find(res->headers, "message", sizeof("message"), (void **)&error_msg) == SUCCESS) {
|
||||
STOMP_ERROR(0, error_msg)
|
||||
frame_destroy(res);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
MAKE_STD_ZVAL(headers);
|
||||
array_init(headers);
|
||||
if (res->headers) {
|
||||
|
|
16
stomp.c
16
stomp.c
|
@ -462,15 +462,6 @@ stomp_frame_t *stomp_read_frame(stomp_t *stomp)
|
|||
f->body_length = stomp_read_buffer(stomp, &f->body);
|
||||
}
|
||||
|
||||
if (0 == strncmp("ERROR", f->command, sizeof("ERROR") - 1)) {
|
||||
char *error_msg = NULL;
|
||||
if (zend_hash_find(f->headers, "message", sizeof("message"), (void **)&error_msg) == SUCCESS) {
|
||||
stomp_set_error(stomp, error_msg, 0);
|
||||
}
|
||||
frame_destroy(f);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return f;
|
||||
}
|
||||
/* }}} */
|
||||
|
@ -491,7 +482,12 @@ int stomp_valid_receipt(stomp_t *stomp, stomp_frame_t *frame) {
|
|||
&& !strcmp(receipt, receipt_id)) {
|
||||
success = 1;
|
||||
}
|
||||
}
|
||||
} else if (0 == strncmp("ERROR", res->command, sizeof("ERROR") - 1)) {
|
||||
char *error_msg = NULL;
|
||||
if (zend_hash_find(res->headers, "message", sizeof("message"), (void **)&error_msg) == SUCCESS) {
|
||||
stomp_set_error(stomp, error_msg, 0);
|
||||
}
|
||||
}
|
||||
frame_destroy(res);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
--TEST--
|
||||
Bug #16930 - readFrame reports error-frames as "timeout"
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("stomp")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
$s = new Stomp();
|
||||
$s->abort('t2');
|
||||
try {
|
||||
var_dump($s->readFrame());
|
||||
} catch(StompException $e) {
|
||||
var_dump($e->getMessage());
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
string(%d) "%s"
|
Loading…
Reference in New Issue