mirror of
https://github.com/lxsang/ant-http
synced 2024-12-26 00:38:21 +01:00
add release handler to unload all running plugin
This commit is contained in:
parent
ab1eb7bcba
commit
84c8875588
BIN
build/httpd
BIN
build/httpd
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
5
httpd.c
5
httpd.c
@ -61,7 +61,9 @@ void load_config(const char* file)
|
|||||||
}
|
}
|
||||||
init_file_system();
|
init_file_system();
|
||||||
}
|
}
|
||||||
|
void stop_serve(int dummy) {
|
||||||
|
unload_all_plugin();
|
||||||
|
}
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
// load the config first
|
// load the config first
|
||||||
@ -81,6 +83,7 @@ int main(int argc, char* argv[])
|
|||||||
//or reading to/from a closed socked connection
|
//or reading to/from a closed socked connection
|
||||||
signal(SIGPIPE, SIG_IGN);
|
signal(SIGPIPE, SIG_IGN);
|
||||||
signal(SIGABRT, SIG_IGN);
|
signal(SIGABRT, SIG_IGN);
|
||||||
|
signal(SIGINT, stop_serve);
|
||||||
server_sock = startup(&port);
|
server_sock = startup(&port);
|
||||||
LOG("httpd running on port %d\n", port);
|
LOG("httpd running on port %d\n", port);
|
||||||
|
|
||||||
|
@ -415,17 +415,33 @@ void * plugin_from_file(char* name)
|
|||||||
*/
|
*/
|
||||||
void unload_all_plugin()
|
void unload_all_plugin()
|
||||||
{
|
{
|
||||||
|
LOG("Unload all plugins\n");
|
||||||
|
void (*fn)();
|
||||||
|
char* error;
|
||||||
for(int i=0;i<HASHSIZE;i++)
|
for(int i=0;i<HASHSIZE;i++)
|
||||||
{
|
{
|
||||||
struct plugin_entry *np;
|
struct plugin_entry *np;
|
||||||
for (np = plugin_table[i]; np != NULL; np = np->next)
|
for (np = plugin_table[i]; np != NULL; np = np->next)
|
||||||
{
|
{
|
||||||
|
// execute the exit function if exists
|
||||||
|
// load the function
|
||||||
|
fn = (void (*)())dlsym(np->handle, "pexit");
|
||||||
|
if ((error = dlerror()) != NULL)
|
||||||
|
{
|
||||||
|
LOG("Cant not find exit method from %s : %s \n", np->pname,error);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// execute it
|
||||||
|
(*fn)();
|
||||||
|
}
|
||||||
dlclose(np->handle);
|
dlclose(np->handle);
|
||||||
free((void *) np->handle);
|
//free((void *) np->handle);
|
||||||
free((void *) np->pname);
|
free((void *) np->pname);
|
||||||
}
|
}
|
||||||
plugin_table[i] = NULL;
|
plugin_table[i] = NULL;
|
||||||
}
|
}
|
||||||
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -186,3 +186,7 @@ void rmfolder(int c, const char* m, dictionary rq)
|
|||||||
//LOG("%s\n",rpath );
|
//LOG("%s\n",rpath );
|
||||||
__t(c,__RESULT__,1,"OK");
|
__t(c,__RESULT__,1,"OK");
|
||||||
}
|
}
|
||||||
|
void pexit()
|
||||||
|
{
|
||||||
|
LOG("Exit file manager,plugins\n");
|
||||||
|
}
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user