mirror of
https://github.com/danog/ext-uv.git
synced 2024-11-30 04:29:01 +01:00
Fix #44 - prepare 0.2.1
This commit is contained in:
parent
c38fbc92b3
commit
a2ab5c8296
11
package.xml
11
package.xml
@ -10,11 +10,11 @@
|
||||
<email>bobwei9@hotmail.com</email>
|
||||
<active>yes</active>
|
||||
</lead>
|
||||
<date>2017-05-07</date>
|
||||
<time>21:00:00</time>
|
||||
<date>2017-05-08</date>
|
||||
<time>11:00:00</time>
|
||||
<version>
|
||||
<release>0.2.0</release>
|
||||
<api>0.2.0</api>
|
||||
<release>0.2.1</release>
|
||||
<api>0.2.1</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>beta</release>
|
||||
@ -22,8 +22,7 @@
|
||||
</stability>
|
||||
<license uri="http://www.php.net/license">PHP License</license>
|
||||
<notes>
|
||||
- Move from resource handles to object handles
|
||||
- Various smaller fixes
|
||||
- Fix memory leak when closing
|
||||
</notes>
|
||||
<contents>
|
||||
<dir name="/">
|
||||
|
17
php_uv.c
17
php_uv.c
@ -1242,10 +1242,11 @@ void static destruct_uv(zend_object *obj)
|
||||
if (uv_cancel(&uv->uv.req) == UV_EBUSY) {
|
||||
++GC_REFCOUNT(obj);
|
||||
}
|
||||
} else if (!uv_is_closing(&uv->uv.handle)) {
|
||||
clean_uv_handle(uv);
|
||||
} else {
|
||||
php_uv_close(uv);
|
||||
/* cleaning happens in close_cb */
|
||||
}
|
||||
clean_uv_handle(uv);
|
||||
}
|
||||
|
||||
void static php_uv_free_write_req(write_req_t *wr) {
|
||||
@ -2039,16 +2040,16 @@ static void php_uv_close_cb(uv_handle_t *handle)
|
||||
php_uv_t *uv = (php_uv_t *) handle->data;
|
||||
TSRMLS_FETCH_FROM_CTX(uv->thread_ctx);
|
||||
|
||||
if (!PHP_UV_IS_DTORED(uv)) {
|
||||
if (uv->callback[PHP_UV_CLOSE_CB]) {
|
||||
ZVAL_OBJ(¶ms[0], (zend_object *) uv);
|
||||
|
||||
php_uv_do_callback2(&retval, uv, params, 1, PHP_UV_CLOSE_CB TSRMLS_CC);
|
||||
zval_ptr_dtor(&retval);
|
||||
|
||||
/* manually clean the uv handle to avoid default dtor handling */
|
||||
clean_uv_handle(uv);
|
||||
}
|
||||
|
||||
/* manually clean the uv handle as dtor will not be called anymore here */
|
||||
clean_uv_handle(uv);
|
||||
|
||||
PHP_UV_DEBUG_OBJ_DEL_REFCOUNT(uv_close_cb, uv);
|
||||
OBJ_RELEASE(&uv->std);
|
||||
}
|
||||
@ -2059,13 +2060,17 @@ static inline zend_bool php_uv_is_handle_referenced(php_uv_t *uv) {
|
||||
return (ce == uv_signal_ce || ce == uv_timer_ce || ce == uv_idle_ce || ce == uv_udp_ce || ce == uv_tcp_ce || ce == uv_tty_ce || ce == uv_pipe_ce || ce == uv_prepare_ce || ce == uv_check_ce || ce == uv_poll_ce || ce == uv_fs_poll_ce) ? uv_is_active(&uv->uv.handle) : (ce == uv_async_ce);
|
||||
}
|
||||
|
||||
/* uv handle must not be cleaned or closed before called */
|
||||
static void php_uv_close(php_uv_t *uv) {
|
||||
ZEND_ASSERT(!uv_is_closing(&uv->uv.handle));
|
||||
|
||||
if (!php_uv_is_handle_referenced(uv)) {
|
||||
++GC_REFCOUNT(&uv->std);
|
||||
PHP_UV_DEBUG_OBJ_ADD_REFCOUNT(php_uv_close, uv);
|
||||
}
|
||||
|
||||
uv_close(&uv->uv.handle, php_uv_close_cb);
|
||||
|
||||
PHP_UV_SKIP_DTOR(uv);
|
||||
}
|
||||
|
||||
|
2
php_uv.h
2
php_uv.h
@ -3,7 +3,7 @@
|
||||
#define PHP_UV_H
|
||||
|
||||
#define PHP_UV_EXTNAME "uv"
|
||||
#define PHP_UV_VERSION "0.2.0"
|
||||
#define PHP_UV_VERSION "0.2.1"
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
|
@ -10,9 +10,7 @@ uv_listen($tcp, 100, function($server){
|
||||
uv_read_start($client, function($socket, $nread, $buffer) use ($server) {
|
||||
echo $buffer . PHP_EOL;
|
||||
uv_close($socket);
|
||||
uv_close($server, function() use ($server) {
|
||||
uv_unref($server);
|
||||
});
|
||||
uv_close($server);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -10,9 +10,7 @@ uv_listen($tcp,100, function($server) {
|
||||
uv_read_start($client, function($socket, $nread, $buffer) use ($server) {
|
||||
echo $buffer . PHP_EOL;
|
||||
uv_close($socket);
|
||||
uv_close($server,function() use ($server) {
|
||||
uv_unref($server);
|
||||
});
|
||||
uv_close($server);
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user