diff options
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 24 |
1 files changed, 12 insertions, 12 deletions
@@ -49,7 +49,7 @@ enum MHD_Result process_connection(void *cls, struct MHD_Connection *connection, } else if (handler != NULL) { /* endpoint access */ LINFOF("Accessed endpoint at url %s", url); - res = handler(connection, &status); + res = handler(method, connection, &status); } else if ((newurl = arg->query(url + 1)) != NULL) { LINFOF("Redirect from %s to %s", url, newurl); response = "<!DOCTYPE html><html><body>Recirecting...</body></html>"; @@ -85,8 +85,8 @@ void reload_dylib(const char *so_path, const char *db_path) { if (!arg.dylib) LCRITVF(1, "Could not open dynamic library: %s\n", dlerror()); arg.query = dlsym(arg.dylib, "db_get_url"); if (!arg.query) LCRITVF(1, "Could not load `db_get_url` from shared library: %s", dlerror()); - arg.constructor = dlsym(arg.dylib, "sqlite_init"); - if (!arg.constructor) LCRITVF(1, "Could not load `sqlite_init` from shared library: %s", dlerror()); + arg.constructor = dlsym(arg.dylib, "init"); + if (!arg.constructor) LCRITVF(1, "Could not load `init` from shared library: %s", dlerror()); arg.constructor(db_path); arg.destructor = dlsym(arg.dylib, "sqlite_deinit"); if (!arg.destructor) LCRITVF(1, "Could not load `sqlite_deinit` from shared library: %s", dlerror()); @@ -118,15 +118,15 @@ int main(int argc, char *argv[]) { const char *dlpath = DEFAULT_ENDPOINTS_PATH; const char *dbpath = DEFAULT_DATABASE_PATH; struct MHD_Daemon *daemon = init(&sig, dlpath, dbpath); - /* while (reload_library == 0) { */ - /* sigsuspend(&sig); */ - /* if (reload_library == 1) { */ - /* reload_dylib(dlpath, dbpath); */ - /* reload_library = 0; */ - /* } */ - /* } */ - getchar(); - if (arg.destructor) arg.destructor(); + while (reload_library == 0) { + sigsuspend(&sig); + if (reload_library == 1) { + reload_dylib(dlpath, dbpath); + reload_library = 0; + } + } + getchar(); /* to be replaced with fork later */ + arg.destructor(); dlclose(arg.dylib); MHD_stop_daemon(daemon); return 0; |