X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fhttp-svc.c;h=3b9db7ad2a4b5c6c95ba0fa662b3ad6516f954dd;hb=14b0b56a3a63df1415b13bf410f8fee2b6661d18;hp=ac5cd7899b24bc2b2882169b8a5bd01cbd8b23b4;hpb=e7c246a1b0d30b8156c7033061a61ecb5d2bdfc8;p=src%2Fapp-framework-binder.git diff --git a/src/http-svc.c b/src/http-svc.c index ac5cd789..3b9db7ad 100644 --- a/src/http-svc.c +++ b/src/http-svc.c @@ -70,14 +70,10 @@ static AFB_error initLibMagic (AFB_session *session) { // Because of POST call multiple time requestApi we need to free POST handle here static void endRequest (void *cls, struct MHD_Connection *connection, void **con_cls, enum MHD_RequestTerminationCode toe) { - AFB_HttpPost *posthandle = *con_cls; + AFB_PostHandle *posthandle = *con_cls; // if post handle was used let's free everything - if (posthandle) { - if (verbose) fprintf (stderr, "End Post Request UID=%d\n", posthandle->uid); - free (posthandle->data); - free (posthandle); - } + if (posthandle != NULL) endPostRequest (posthandle); } @@ -107,6 +103,7 @@ STATIC int servFile (struct MHD_Connection *connection, AFB_session *session, co // No trailing '/'. Let's add one and redirect for relative paths to work if (url [strlen (url) -1] != '/') { response = MHD_create_response_from_buffer(0,"", MHD_RESPMEM_PERSISTENT); + strncpy(staticfile->path, url, sizeof (staticfile->path)); strncat(staticfile->path, "/", sizeof (staticfile->path)); MHD_add_response_header (response, "Location", staticfile->path); MHD_queue_response (connection, MHD_HTTP_MOVED_PERMANENTLY, response); @@ -270,9 +267,12 @@ PUBLIC AFB_error httpdStart(AFB_session *session) { apiUrlLen = strlen (session->config->rootapi); baseUrlLen= strlen (session->config->rootbase); rootUrlLen= strlen (session->config->rootdir); + + // Initialise Client Session Hash Table + ctxStoreInit (CTX_NBCLIENTS); - // TBD open libmagic cache [fail to pass EFENCE check] - // initLibMagic (session); + //TBD open libmagic cache [fail to pass EFENCE check (allocating 0 bytes)] + //initLibMagic (session); if (verbose) { @@ -298,20 +298,11 @@ PUBLIC AFB_error httpdStart(AFB_session *session) { // infinite loop PUBLIC AFB_error httpdLoop(AFB_session *session) { - static int count = 0; - + int count = 0; if (verbose) fprintf(stderr, "AFB:notice entering httpd waiting loop\n"); - if (session->foreground) { - - while (TRUE) { - fprintf(stderr, "AFB:notice Use Ctrl-C to quit\n"); - (void) getc(stdin); - } - } else { - while (TRUE) { - sleep(3600); - if (verbose) fprintf(stderr, "AFB:notice httpd alive [%d]\n", count++); - } + while (TRUE) { + sleep(3600); + if (verbose) fprintf(stderr, "AFB:notice httpd alive [%d]\n", count++); } // should never return from here