From fbacdccd374c89c719752ed0b4d1e806f8cc391b Mon Sep 17 00:00:00 2001 From: Gennady Feldman Date: Tue, 5 May 2015 10:17:49 -0400 Subject: [PATCH] Fix error checking after stomp_send(). This one has been in there for a while and would hang for me in 1.0.6 release if the connection was refused. Some tests would fail too. This error was also somewhat masked in previous release. We should abort and throw an exception if send fails. --- php_stomp.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/php_stomp.c b/php_stomp.c index 84482cd..81bf8e9 100755 --- a/php_stomp.c +++ b/php_stomp.c @@ -549,8 +549,15 @@ PHP_FUNCTION(stomp_connect) FRAME_HEADER_FROM_HASHTABLE(frame.headers, Z_ARRVAL_P(headers)); } - stomp_send(stomp, &frame TSRMLS_CC); + res = stomp_send(stomp, &frame TSRMLS_CC); CLEAR_FRAME(frame); + if (0 == res) { + zval *excobj = zend_throw_exception_ex(stomp_ce_exception, stomp->errnum TSRMLS_CC, stomp->error); + if (stomp->error_details) { + zend_update_property_string(stomp_ce_exception, excobj, "details", sizeof("details")-1, stomp->error_details TSRMLS_CC); + } + return; + } /* Retreive Response */ res = stomp_read_frame(stomp);