Skip to content

Commit

Permalink
Prohibit serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
matyhtf committed Sep 1, 2017
1 parent 4f08ae7 commit 62147b1
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions php_swoole.h
Expand Up @@ -250,6 +250,7 @@ PHP_FUNCTION(swoole_cpu_num);
PHP_FUNCTION(swoole_set_process_name);
PHP_FUNCTION(swoole_get_local_ip);
PHP_FUNCTION(swoole_get_local_mac);
PHP_FUNCTION(swoole_unsupport_serialize);

//---------------------------------------------------------
// swoole_server
Expand Down
5 changes: 5 additions & 0 deletions swoole.c
Expand Up @@ -1070,6 +1070,11 @@ PHP_FUNCTION(swoole_version)
SW_RETURN_STRING(swoole_version, 1);
}

PHP_FUNCTION(swoole_unsupport_serialize)
{
zend_throw_exception_ex(swoole_exception_class_entry_ptr, 0, "cannot serialize or unserialize.");
}

static PHP_FUNCTION(swoole_last_error)
{
RETURN_LONG(SwooleG.error);
Expand Down
2 changes: 2 additions & 0 deletions swoole_atomic.c
Expand Up @@ -115,6 +115,8 @@ static const zend_function_entry swoole_atomic_methods[] =
PHP_ME(swoole_atomic, wait, arginfo_swoole_atomic_wait, ZEND_ACC_PUBLIC)
PHP_ME(swoole_atomic, wakeup, arginfo_swoole_atomic_waitup, ZEND_ACC_PUBLIC)
PHP_ME(swoole_atomic, cmpset, arginfo_swoole_atomic_cmpset, ZEND_ACC_PUBLIC)
PHP_FALIAS(__sleep, swoole_unsupport_serialize, NULL)
PHP_FALIAS(__wakeup, swoole_unsupport_serialize, NULL)
PHP_FE_END
};

Expand Down
2 changes: 2 additions & 0 deletions swoole_buffer.c
Expand Up @@ -70,6 +70,8 @@ static const zend_function_entry swoole_buffer_methods[] =
PHP_ME(swoole_buffer, expand, arginfo_swoole_buffer_expand, ZEND_ACC_PUBLIC)
PHP_ME(swoole_buffer, recycle, arginfo_swoole_buffer_void, ZEND_ACC_PUBLIC)
PHP_ME(swoole_buffer, clear, arginfo_swoole_buffer_void, ZEND_ACC_PUBLIC)
PHP_FALIAS(__sleep, swoole_unsupport_serialize, NULL)
PHP_FALIAS(__wakeup, swoole_unsupport_serialize, NULL)
PHP_FE_END
};

Expand Down
4 changes: 4 additions & 0 deletions swoole_http_server.c
Expand Up @@ -380,6 +380,8 @@ const zend_function_entry swoole_http_server_methods[] =
const zend_function_entry swoole_http_request_methods[] =
{
PHP_ME(swoole_http_request, rawcontent, arginfo_swoole_http_void, ZEND_ACC_PUBLIC)
PHP_FALIAS(__sleep, swoole_unsupport_serialize, NULL)
PHP_FALIAS(__wakeup, swoole_unsupport_serialize, NULL)
PHP_ME(swoole_http_request, __destruct, arginfo_swoole_http_void, ZEND_ACC_PUBLIC | ZEND_ACC_DTOR)
PHP_FE_END
};
Expand All @@ -400,6 +402,8 @@ const zend_function_entry swoole_http_response_methods[] =
PHP_ME(swoole_http_response, write, arginfo_swoole_http_response_write, ZEND_ACC_PUBLIC)
PHP_ME(swoole_http_response, end, arginfo_swoole_http_response_end, ZEND_ACC_PUBLIC)
PHP_ME(swoole_http_response, sendfile, arginfo_swoole_http_response_sendfile, ZEND_ACC_PUBLIC)
PHP_FALIAS(__sleep, swoole_unsupport_serialize, NULL)
PHP_FALIAS(__wakeup, swoole_unsupport_serialize, NULL)
PHP_ME(swoole_http_response, __destruct, arginfo_swoole_http_void, ZEND_ACC_PUBLIC | ZEND_ACC_DTOR)
PHP_FE_END
};
Expand Down
3 changes: 2 additions & 1 deletion swoole_server.c
Expand Up @@ -1543,14 +1543,15 @@ PHP_METHOD(swoole_server, __construct)
zval *ports;
SW_ALLOC_INIT_ZVAL(ports);
array_init(ports);
zend_update_property(swoole_server_class_entry_ptr, server_object, ZEND_STRL("ports"), ports TSRMLS_CC);
server_port_list.zports = ports;

swListenPort *ls;
LL_FOREACH(serv->listen_list, ls)
{
php_swoole_server_add_port(ls TSRMLS_CC);
}

zend_update_property(swoole_server_class_entry_ptr, server_object, ZEND_STRL("ports"), ports TSRMLS_CC);
}

PHP_METHOD(swoole_server, __destruct)
Expand Down
2 changes: 2 additions & 0 deletions swoole_table.c
Expand Up @@ -138,6 +138,8 @@ static const zend_function_entry swoole_table_methods[] =
PHP_ME(swoole_table, offsetGet, arginfo_swoole_table_offsetGet, ZEND_ACC_PUBLIC)
PHP_ME(swoole_table, offsetSet, arginfo_swoole_table_offsetSet, ZEND_ACC_PUBLIC)
PHP_ME(swoole_table, offsetUnset, arginfo_swoole_table_offsetUnset, ZEND_ACC_PUBLIC)
PHP_FALIAS(__sleep, swoole_unsupport_serialize, NULL)
PHP_FALIAS(__wakeup, swoole_unsupport_serialize, NULL)
#ifdef HAVE_PCRE
PHP_ME(swoole_table, rewind, arginfo_swoole_table_void, ZEND_ACC_PUBLIC)
PHP_ME(swoole_table, next, arginfo_swoole_table_void, ZEND_ACC_PUBLIC)
Expand Down

0 comments on commit 62147b1

Please sign in to comment.