Skip to content

Commit 59ec22b

Browse files
committed
sendrecvmsg_shutdown function moved to mshutdown
The function php_socket_sendrecvmsg_shutdown() should have been called in MSHUTDOWN, not RSHUTDOWN. Bug only on TSRM builds. Should fix bug #64287.
1 parent 189fbfd commit 59ec22b

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ PHP NEWS
66
. Fixed bug #49348 (Uninitialized ++$foo->bar; does not cause a notice).
77
(Stas)
88

9+
- Sockets:
10+
. Fixed bug #64287 (sendmsg/recvmsg shutdown handler causes segfault).
11+
(Gustavo)
12+
913
21 Feb 2013, PHP 5.5.0 Alpha 5
1014

1115
- Core:

ext/sockets/sockets.c

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
#include "sendrecvmsg.h"
7070

7171
ZEND_DECLARE_MODULE_GLOBALS(sockets)
72-
static PHP_GINIT_FUNCTION(sockets);
7372

7473
#ifndef MSG_WAITALL
7574
#ifdef LINUX
@@ -271,9 +270,11 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_socket_cmsg_space, 0, 0, 2)
271270
ZEND_END_ARG_INFO()
272271
/* }}} */
273272

274-
PHP_MINIT_FUNCTION(sockets);
275-
PHP_MINFO_FUNCTION(sockets);
276-
PHP_RSHUTDOWN_FUNCTION(sockets);
273+
static PHP_GINIT_FUNCTION(sockets);
274+
static PHP_MINIT_FUNCTION(sockets);
275+
static PHP_MSHUTDOWN_FUNCTION(sockets);
276+
static PHP_MINFO_FUNCTION(sockets);
277+
static PHP_RSHUTDOWN_FUNCTION(sockets);
277278

278279
PHP_FUNCTION(socket_select);
279280
PHP_FUNCTION(socket_create_listen);
@@ -356,7 +357,7 @@ zend_module_entry sockets_module_entry = {
356357
"sockets",
357358
sockets_functions,
358359
PHP_MINIT(sockets),
359-
NULL,
360+
PHP_MSHUTDOWN(sockets),
360361
NULL,
361362
PHP_RSHUTDOWN(sockets),
362363
PHP_MINFO(sockets),
@@ -607,7 +608,7 @@ static PHP_GINIT_FUNCTION(sockets)
607608

608609
/* {{{ PHP_MINIT_FUNCTION
609610
*/
610-
PHP_MINIT_FUNCTION(sockets)
611+
static PHP_MINIT_FUNCTION(sockets)
611612
{
612613
le_socket = zend_register_list_destructors_ex(php_destroy_socket, NULL, le_socket_name, module_number);
613614

@@ -728,9 +729,19 @@ PHP_MINIT_FUNCTION(sockets)
728729
}
729730
/* }}} */
730731

732+
/* {{{ PHP_MSHUTDOWN_FUNCTION
733+
*/
734+
static PHP_MSHUTDOWN_FUNCTION(sockets)
735+
{
736+
php_socket_sendrecvmsg_shutdown(SHUTDOWN_FUNC_ARGS_PASSTHRU);
737+
738+
return SUCCESS;
739+
}
740+
/* }}} */
741+
731742
/* {{{ PHP_MINFO_FUNCTION
732743
*/
733-
PHP_MINFO_FUNCTION(sockets)
744+
static PHP_MINFO_FUNCTION(sockets)
734745
{
735746
php_info_print_table_start();
736747
php_info_print_table_row(2, "Sockets Support", "enabled");
@@ -739,13 +750,12 @@ PHP_MINFO_FUNCTION(sockets)
739750
/* }}} */
740751

741752
/* {{{ PHP_RSHUTDOWN_FUNCTION */
742-
PHP_RSHUTDOWN_FUNCTION(sockets)
753+
static PHP_RSHUTDOWN_FUNCTION(sockets)
743754
{
744755
if (SOCKETS_G(strerror_buf)) {
745756
efree(SOCKETS_G(strerror_buf));
746757
SOCKETS_G(strerror_buf) = NULL;
747758
}
748-
php_socket_sendrecvmsg_shutdown(SHUTDOWN_FUNC_ARGS_PASSTHRU);
749759

750760
return SUCCESS;
751761
}

0 commit comments

Comments
 (0)