diff --git a/build/httpd b/build/httpd index 1ab524e..e7d5ab8 100755 Binary files a/build/httpd and b/build/httpd differ diff --git a/build/httpd.dSYM/Contents/Resources/DWARF/httpd b/build/httpd.dSYM/Contents/Resources/DWARF/httpd index 0917e15..0f731fb 100644 Binary files a/build/httpd.dSYM/Contents/Resources/DWARF/httpd and b/build/httpd.dSYM/Contents/Resources/DWARF/httpd differ diff --git a/build/plugins/dummy.dylib b/build/plugins/dummy.dylib index 812c85a..0505c15 100755 Binary files a/build/plugins/dummy.dylib and b/build/plugins/dummy.dylib differ diff --git a/build/plugins/fileman.dylib b/build/plugins/fileman.dylib index bbc7e79..7cb8019 100755 Binary files a/build/plugins/fileman.dylib and b/build/plugins/fileman.dylib differ diff --git a/build/plugins/pluginsman.dylib b/build/plugins/pluginsman.dylib index c0b2955..6650feb 100755 Binary files a/build/plugins/pluginsman.dylib and b/build/plugins/pluginsman.dylib differ diff --git a/httpd.c b/httpd.c index e329964..58eba66 100644 --- a/httpd.c +++ b/httpd.c @@ -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); diff --git a/plugin_manager.c b/plugin_manager.c index e115770..eb39df6 100644 --- a/plugin_manager.c +++ b/plugin_manager.c @@ -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;inext) { + // 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); } /** diff --git a/plugins/fileman/fileman.c b/plugins/fileman/fileman.c index ec60dc8..0689f5d 100644 --- a/plugins/fileman/fileman.c +++ b/plugins/fileman/fileman.c @@ -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"); +} \ No newline at end of file diff --git a/plugins/fileman/fileman.c.o b/plugins/fileman/fileman.c.o index cbf59a5..a0e5a9c 100644 Binary files a/plugins/fileman/fileman.c.o and b/plugins/fileman/fileman.c.o differ