Fix bug 16933

v1.1
Pierrick Charron 2009-11-14 22:48:32 +00:00
parent 87b67a302d
commit 265f925b84
2 changed files with 18 additions and 4 deletions

View File

@ -796,6 +796,7 @@ PHP_FUNCTION(stomp_read_frame)
zval *stomp_object = getThis();
stomp_t *stomp = NULL;
stomp_frame_t *res = NULL;
int sel_res = 0;
if (stomp_object) {
stomp_object_t *i_obj = NULL;
@ -808,7 +809,7 @@ PHP_FUNCTION(stomp_read_frame)
ZEND_FETCH_RESOURCE(stomp, stomp_t *, &arg, -1, PHP_STOMP_RES_NAME, le_stomp);
}
if (stomp_select(stomp) > 0 && (res = stomp_read_frame(stomp))) {
if ((sel_res = stomp_select(stomp)) > 0 && (res = stomp_read_frame(stomp))) {
zval *headers = NULL;
if (0 == strncmp("ERROR", res->command, sizeof("ERROR") - 1)) {
@ -855,6 +856,9 @@ PHP_FUNCTION(stomp_read_frame)
frame_destroy(res);
} else {
if (sel_res == -1) {
STOMP_ERROR(0, "Error while selecting from socket: %d", errno);
}
RETURN_FALSE;
}
}

16
stomp.c
View File

@ -23,6 +23,7 @@
#endif
#include "php.h"
#include "zend_exceptions.h"
#include "ext/standard/php_smart_str.h"
#include "stomp.h"
#include "php_stomp.h"
@ -30,6 +31,7 @@
#define RETURN_READ_FRAME_FAIL { frame_destroy(f); return NULL; }
ZEND_EXTERN_MODULE_GLOBALS(stomp);
extern stomp_ce_exception;
/* {{{ stomp_new
*/
@ -249,15 +251,23 @@ int stomp_send(stomp_t *stomp, stomp_frame_t *frame TSRMLS_DC)
*/
int stomp_recv(stomp_t *stomp, char *msg, size_t length)
{
int len;
#if HAVE_STOMP_SSL
if(stomp->use_ssl) {
return SSL_read(stomp->ssl_handle, msg, length);
len = SSL_read(stomp->ssl_handle, msg, length);
} else {
#endif
return recv(stomp->fd, msg, length, 0);
len = recv(stomp->fd, msg, length, 0);
#if HAVE_STOMP_SSL
}
#endif
#endif
if (len == 0) {
TSRMLS_FETCH();
zend_throw_exception_ex(stomp_ce_exception, errno TSRMLS_CC, "Unexpected EOF while reading from socket");
stomp->status = -1;
}
return len;
}
/* }}} */