v1.1
Pierrick Charron 2009-11-14 22:05:01 +00:00
parent 6150f2f373
commit 87b67a302d
3 changed files with 33 additions and 10 deletions

View File

@ -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
View File

@ -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);
}
}

17
tests/bug_16930.phpt Normal file
View File

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