2004-07-29 10:59:44 +08:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
2014-09-20 00:33:14 +08:00
|
|
|
| PHP Version 7 |
|
2004-07-29 10:59:44 +08:00
|
|
|
+----------------------------------------------------------------------+
|
2017-01-02 23:30:12 +08:00
|
|
|
| Copyright (c) 1997-2017 The PHP Group |
|
2004-07-29 10:59:44 +08:00
|
|
|
+----------------------------------------------------------------------+
|
2006-01-01 20:51:34 +08:00
|
|
|
| This source file is subject to version 3.01 of the PHP license, |
|
2004-07-29 10:59:44 +08:00
|
|
|
| that is bundled with this package in the file LICENSE, and is |
|
|
|
|
| available through the world-wide-web at the following url: |
|
2006-01-01 20:51:34 +08:00
|
|
|
| http://www.php.net/license/3_01.txt |
|
2004-07-29 10:59:44 +08:00
|
|
|
| If you did not receive a copy of the PHP license and are unable to |
|
|
|
|
| obtain it through the world-wide-web, please send a note to |
|
|
|
|
| license@php.net so we can mail you a copy immediately. |
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
| Author: Wez Furlong <wez@php.net> |
|
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
#include "php.h"
|
|
|
|
#include "php_win32_globals.h"
|
2006-11-10 19:42:07 +08:00
|
|
|
#include "syslog.h"
|
2004-07-29 10:59:44 +08:00
|
|
|
|
|
|
|
#ifdef ZTS
|
reworked the patch, less new stuff but worky
TLS is already used in TSRM, the way exporting the tsrm cache through
a thread local variable is not portable. Additionally, the current
patch suffers from bugs which are hard to find, but prevent it to
be worky with apache. What is done here is mainly uses the idea
from the RFC patch, but
- __thread variable is removed
- offset math and declarations are removed
- extra macros and definitions are removed
What is done merely is
- use an inline function to access the tsrm cache. The function uses
the portable tsrm_tls_get macro which is cheap
- all the TSRM_* macros are set to placebo. Thus this opens the way
remove them later
Except that, the logic is old. TSRMLS_FETCH will have to be done once
per thread, then tsrm_get_ls_cache() can be used. Things seeming to be
worky are cli, cli server and apache. I also tried to enable bz2
shared and it has worked out of the box. The change is yet minimal
diffing to the current master bus is a worky start, IMHO. Though will
have to recheck the other previously done SAPIs - embed and cgi.
The offsets can be added to the tsrm_resource_type struct, then
it'll not be needed to declare them in the userspace. Even the
"done" member type can be changed to int16 or smaller, then adding
the offset as int16 will not change the struct size. As well on the
todo might be removing the hashed storage, thread_id != thread_id and
linked list logic in favour of the explicit TLS operations.
2014-09-26 00:48:27 +08:00
|
|
|
PHPAPI int php_win32_core_globals_id;
|
2004-07-29 10:59:44 +08:00
|
|
|
#else
|
2004-08-01 01:28:27 +08:00
|
|
|
php_win32_core_globals the_php_win32_core_globals;
|
2004-07-29 10:59:44 +08:00
|
|
|
#endif
|
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
void php_win32_core_globals_ctor(void *vg)
|
2017-07-04 22:08:48 +08:00
|
|
|
{/*{{{*/
|
2004-07-29 10:59:44 +08:00
|
|
|
php_win32_core_globals *wg = (php_win32_core_globals*)vg;
|
|
|
|
memset(wg, 0, sizeof(*wg));
|
2015-03-04 17:22:51 +08:00
|
|
|
|
|
|
|
wg->mail_socket = INVALID_SOCKET;
|
2015-03-12 02:07:46 +08:00
|
|
|
|
|
|
|
wg->log_source = INVALID_HANDLE_VALUE;
|
2017-07-04 22:08:48 +08:00
|
|
|
}/*}}}*/
|
2004-07-29 10:59:44 +08:00
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
void php_win32_core_globals_dtor(void *vg)
|
2017-07-04 22:08:48 +08:00
|
|
|
{/*{{{*/
|
2006-11-10 19:42:07 +08:00
|
|
|
php_win32_core_globals *wg = (php_win32_core_globals*)vg;
|
|
|
|
|
|
|
|
if (wg->registry_key) {
|
|
|
|
RegCloseKey(wg->registry_key);
|
|
|
|
wg->registry_key = NULL;
|
|
|
|
}
|
|
|
|
if (wg->registry_event) {
|
|
|
|
CloseHandle(wg->registry_event);
|
|
|
|
wg->registry_event = NULL;
|
|
|
|
}
|
|
|
|
if (wg->registry_directories) {
|
|
|
|
zend_hash_destroy(wg->registry_directories);
|
|
|
|
free(wg->registry_directories);
|
|
|
|
wg->registry_directories = NULL;
|
|
|
|
}
|
2015-03-04 17:22:51 +08:00
|
|
|
|
|
|
|
if (INVALID_SOCKET != wg->mail_socket) {
|
|
|
|
closesocket(wg->mail_socket);
|
2015-03-12 03:41:27 +08:00
|
|
|
wg->mail_socket = INVALID_SOCKET;
|
2015-03-04 17:22:51 +08:00
|
|
|
}
|
2017-07-04 22:08:48 +08:00
|
|
|
}/*}}}*/
|
2006-11-10 19:42:07 +08:00
|
|
|
|
|
|
|
|
2004-07-29 10:59:44 +08:00
|
|
|
PHP_RSHUTDOWN_FUNCTION(win32_core_globals)
|
2017-07-04 22:08:48 +08:00
|
|
|
{/*{{{*/
|
2004-07-29 10:59:44 +08:00
|
|
|
php_win32_core_globals *wg =
|
|
|
|
#ifdef ZTS
|
|
|
|
ts_resource(php_win32_core_globals_id)
|
|
|
|
#else
|
2004-08-01 01:28:27 +08:00
|
|
|
&the_php_win32_core_globals
|
2004-07-29 10:59:44 +08:00
|
|
|
#endif
|
|
|
|
;
|
|
|
|
|
2006-11-10 19:42:07 +08:00
|
|
|
closelog();
|
|
|
|
|
2004-07-29 11:58:00 +08:00
|
|
|
return SUCCESS;
|
2017-07-04 22:08:48 +08:00
|
|
|
}/*}}}*/
|
2004-07-29 10:59:44 +08:00
|
|
|
|
2015-05-21 00:51:19 +08:00
|
|
|
/*
|
|
|
|
* Local variables:
|
|
|
|
* tab-width: 4
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* End:
|
|
|
|
* vim600: sw=4 ts=4 fdm=marker
|
|
|
|
* vim<600: sw=4 ts=4
|
|
|
|
*/
|