-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathphp_mshutdown.c
65 lines (53 loc) · 1.75 KB
/
php_mshutdown.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
* Copyright 2020 New Relic Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* This file handles the termination that happens once per module.
*/
#include "php_agent.h"
#include <signal.h>
#include <sys/wait.h>
#include "php_globals.h"
#include "php_internal_instrument.h"
#include "php_user_instrument.h"
#include "php_vm.h"
#include "nr_agent.h"
#include "util_logging.h"
#include "fw_wordpress.h"
#include "lib_aws_sdk_php.h"
#ifdef TAGS
void zm_shutdown_newrelic(void); /* ctags landing pad only */
#endif
PHP_MSHUTDOWN_FUNCTION(newrelic) {
(void)type;
(void)module_number;
NR_UNUSED_TSRMLS;
if (0 == NR_PHP_PROCESS_GLOBALS(enabled)) {
return SUCCESS;
}
/*
* Note: When shutting down, each PHP process will perform this MSHUTDOWN
* regardless of whether or not it performed a MINIT: For example, in the
* Apache worker situation, every PHP worker process will run this function,
* not just the parent master process. Therefore, this function must not
* do any work that should only be completed by a single web server process.
*
* It is assumed that this MSHUTDOWN is only done once per PHP process.
*/
nrl_debug(NRL_INIT, "MSHUTDOWN processing started");
nr_wordpress_mshutdown();
#if ZEND_MODULE_API_NO >= ZEND_8_1_X_API_NO /* PHP 8.1+ */
nr_aws_sdk_mshutdown();
#endif
/* restore header handler */
sapi_module.header_handler = NR_PHP_PROCESS_GLOBALS(orig_header_handler);
NR_PHP_PROCESS_GLOBALS(orig_header_handler) = NULL;
nr_agent_close_daemon_connection();
nrl_close_log_file();
nr_php_remove_opcode_handlers();
nr_php_destroy_internal_wrap_records();
nr_php_destroy_user_wrap_records();
nr_php_global_destroy();
nr_applist_destroy(&nr_agent_applist);
return SUCCESS;
}