In php extension, the global object instance in c ++ Singleton mode is destroyed by multiple sub-processes. why? How to solve
Source: Internet
Author: User
In php extension, the global object instance in c ++ Singleton mode is destroyed by multiple sub-processes. why ?? In php extension, a global object in Singleton mode is used. when the http service is stopped, the log is used to view and print the process number. it is found that the destructor is called multiple times, it is in different processes (observed by process numbers ). Why! In php extension, the global object instance in c ++ Singleton mode is destroyed by multiple sub-processes. why ??
In php extension, a global object in Singleton mode is used. when the http service is stopped, the log is used to view and print the process number. it is found that the destructor is called multiple times, it is in different processes (observed by process numbers ). Why! It doesn't mean that the http service is started once. Will the global object be instantiated once! How can so many strange phenomena occur when the service is stopped!
------ Solution --------------------
How do you know that the destructor are called multiple times? In addition, have you been instantiated multiple times in the program?
------ Solution --------------------
Who is responding to the HTTP request? Apache, IIS...
What is the status of PHP in HTTP requests? Web server applications
Therefore, every PHP-related HTTP request will trigger a PHP process
Your scaling is dynamically linked to the inventory, and is independent in the (line) process.
If you want to share your extended classes with other threads, you must modify the php Kernel. However, this kernel is not open-source in any system, all provided in the library mode
------ Solution --------------------
Php runs on cgi. it does not stop constructing and analyzing the structure, because every time a new Php interpreter process loads a bunch of dynamic libraries, this includes your static C ++ object. each PHP process loads the same dynamic library, but their memory is isolated.
The landlord uses fcgi to run php differently. a new fcgi process will be created only when the number of concurrent requests exceeds the current number of fcgi processes, but it is certainly not shared by multiple processes.
------ Solution --------------------
Discussion
Started in apache. If you say that, then the global object cannot be used in my php extension! Dizzy!
Reference:
Who is responding to the HTTP request? Apache, IIS...
What is the status of PHP in HTTP requests? Web server applications
Therefore, every PHP-related HTTP request will trigger a PHP process
Your scaling is dynamically linked to the inventory, and is independent in the (line) process.
......
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.