HPHP: add mechanism to add hooks around server start.
Add mechanism to add hook around server start. Similar to the existing Thread/Process Init/Fini hooks. This allows us to add behaviors around the main hphp server start/stop event without introducing source code level dependency.
Esse commit está contido em:
@@ -76,8 +76,9 @@ extern char **environ;
|
||||
namespace HPHP {
|
||||
|
||||
extern InitFiniNode *extra_process_init, *extra_process_exit;
|
||||
extern InitFiniNode *extra_server_init, *extra_server_exit;
|
||||
|
||||
void initialize_repo();
|
||||
void initialize_repo();
|
||||
|
||||
/*
|
||||
* XXX: VM process initialization is handled through a function
|
||||
@@ -680,7 +681,13 @@ static int start_server(const std::string &username) {
|
||||
}
|
||||
}
|
||||
|
||||
for (InitFiniNode *in = extra_server_init; in; in = in->next) {
|
||||
in->func();
|
||||
}
|
||||
HttpServer::Server->run();
|
||||
for (InitFiniNode *in = extra_server_exit; in; in = in->next) {
|
||||
in->func();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,13 +35,15 @@ namespace HPHP {
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
InitFiniNode *extra_init, *extra_fini, *extra_process_init, *extra_process_exit;
|
||||
InitFiniNode *extra_server_init, *extra_server_exit;
|
||||
|
||||
InitFiniNode::InitFiniNode(void(*f)(), When init) {
|
||||
InitFiniNode *&ifn =
|
||||
init == When::ThreadInit ? extra_init :
|
||||
init == When::ThreadFini ? extra_fini :
|
||||
init == When::ProcessInit ? extra_process_init : extra_process_exit;
|
||||
|
||||
init == When::ProcessInit ? extra_process_init :
|
||||
init == When::ProcessExit ? extra_process_exit :
|
||||
init == When::ServerInit ? extra_server_init : extra_server_exit;
|
||||
func = f;
|
||||
next = ifn;
|
||||
ifn = this;
|
||||
|
||||
@@ -32,7 +32,9 @@ struct InitFiniNode {
|
||||
ThreadInit,
|
||||
ThreadFini,
|
||||
ProcessInit,
|
||||
ProcessExit
|
||||
ProcessExit,
|
||||
ServerInit,
|
||||
ServerExit
|
||||
};
|
||||
InitFiniNode(void(*f)(), When when);
|
||||
void (*func)();
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário