1
0
mirror of https://github.com/lxsang/ant-http synced 2024-07-01 12:59:47 +02:00

add release handler to unload all running plugin

This commit is contained in:
LE Xuan Sang 2015-10-22 23:13:53 +02:00
parent ab1eb7bcba
commit 84c8875588
9 changed files with 25 additions and 2 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -61,7 +61,9 @@ void load_config(const char* file)
}
init_file_system();
}
void stop_serve(int dummy) {
unload_all_plugin();
}
int main(int argc, char* argv[])
{
// load the config first
@ -81,6 +83,7 @@ int main(int argc, char* argv[])
//or reading to/from a closed socked connection
signal(SIGPIPE, SIG_IGN);
signal(SIGABRT, SIG_IGN);
signal(SIGINT, stop_serve);
server_sock = startup(&port);
LOG("httpd running on port %d\n", port);

View File

@ -415,17 +415,33 @@ void * plugin_from_file(char* name)
*/
void unload_all_plugin()
{
LOG("Unload all plugins\n");
void (*fn)();
char* error;
for(int i=0;i<HASHSIZE;i++)
{
struct plugin_entry *np;
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);
free((void *) np->handle);
//free((void *) np->handle);
free((void *) np->pname);
}
plugin_table[i] = NULL;
}
exit(0);
}
/**

View File

@ -186,3 +186,7 @@ void rmfolder(int c, const char* m, dictionary rq)
//LOG("%s\n",rpath );
__t(c,__RESULT__,1,"OK");
}
void pexit()
{
LOG("Exit file manager,plugins\n");
}

Binary file not shown.