From 1ebd3d8621f8229d278eb7aad69d943e467295ca Mon Sep 17 00:00:00 2001 From: Marcel Oelke Date: Wed, 29 Jul 2015 11:22:56 +0200 Subject: [PATCH 1/3] Fixed Segmentation fault when try to get data after disconnect (#13). Throws exception instead. Connection state is set to 'disconnected'. --- mogilefs.c | 12 ++++++++---- package.xml | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/mogilefs.c b/mogilefs.c index d040fe9..d8d0e92 100644 --- a/mogilefs.c +++ b/mogilefs.c @@ -345,11 +345,10 @@ PHPAPI int mogilefs_sock_disconnect(MogilefsSock *mogilefs_sock TSRMLS_DC) { /* /* }}} */ PHPAPI int mogilefs_sock_close(MogilefsSock *mogilefs_sock TSRMLS_DC) { /* {{{ */ - if (mogilefs_sock->stream == NULL) { - return 0; - } mogilefs_sock->status = MOGILEFS_SOCK_STATUS_DISCONNECTED; - php_stream_close(mogilefs_sock->stream); + if (mogilefs_sock->stream != NULL) { + php_stream_close(mogilefs_sock->stream); + } mogilefs_sock->stream = NULL; return 1; } @@ -430,6 +429,11 @@ PHPAPI int mogilefs_sock_get(zval *id, MogilefsSock **mogilefs_sock TSRMLS_DC) { /* }}} */ PHPAPI int mogilefs_sock_eof(MogilefsSock *mogilefs_sock) { /* {{{ */ + if (!mogilefs_sock || mogilefs_sock->stream == NULL) { + mogilefs_sock_close(mogilefs_sock); + zend_throw_exception(mogilefs_exception_ce, "Lost tracker connection", 0 TSRMLS_CC); + return 1; + } if (php_stream_eof(mogilefs_sock->stream)) { /* close socket but avoid writing on it again */ mogilefs_sock_close(mogilefs_sock); diff --git a/package.xml b/package.xml index 89ed1d0..0986c49 100644 --- a/package.xml +++ b/package.xml @@ -11,9 +11,9 @@ PHP MogileFS is a client library to communicate with MogileFS trackers. Those tr lstrojny@php.net yes - 2013-01-11 + 2015-07-29 - 0.9.4-dev + 0.9.4-rg 1.0 From 387fd5e3ae1083848981ce8c40ce2e11fed0bc61 Mon Sep 17 00:00:00 2001 From: Bastian Hofmann Date: Wed, 29 Jul 2015 13:58:51 +0200 Subject: [PATCH 2/3] Fixed version number for pecl --- package.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.xml b/package.xml index 0986c49..ff83c1a 100644 --- a/package.xml +++ b/package.xml @@ -13,7 +13,7 @@ PHP MogileFS is a client library to communicate with MogileFS trackers. Those tr 2015-07-29 - 0.9.4-rg + 0.9.49 1.0 From de20d3986c4faa5d48162aa3873c393815c3cfc8 Mon Sep 17 00:00:00 2001 From: Marcel Oelke Date: Wed, 29 Jul 2015 14:41:27 +0200 Subject: [PATCH 3/3] Version bump to 0.9.49 --- php_mogilefs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php_mogilefs.h b/php_mogilefs.h index 2a1cfd2..4561239 100644 --- a/php_mogilefs.h +++ b/php_mogilefs.h @@ -32,7 +32,7 @@ #ifndef PHP_MOGILEFS_H #define PHP_MOGILEFS_H -#define PHP_MOGILEFS_VERSION "0.9.2-dev" +#define PHP_MOGILEFS_VERSION "0.9.49" extern zend_module_entry mogilefs_module_entry; #define phpext_mogilefs_ptr &mogilefs_module_entry