Skip to content

Commit

Permalink
Merge pull request #14 from researchgate/master
Browse files Browse the repository at this point in the history
Fixed Segmentation fault when try to get data after disconnect (#13)
  • Loading branch information
lstrojny committed Jul 29, 2015
2 parents 651a0ce + de20d39 commit dd73a2e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
12 changes: 8 additions & 4 deletions mogilefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ PHP MogileFS is a client library to communicate with MogileFS trackers. Those tr
<email>[email protected]</email>
<active>yes</active>
</lead>
<date>2013-01-11</date>
<date>2015-07-29</date>
<version>
<release>0.9.4-dev</release>
<release>0.9.49</release>
<api>1.0</api>
</version>
<stability>
Expand Down
2 changes: 1 addition & 1 deletion php_mogilefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit dd73a2e

Please sign in to comment.