// 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);
}
}
// Nothing respond to this request Files, API, Angular Base
- const char *errorstr = "<html><body>Alsa-Json-Gateway Unknown or Not readable file</body></html>";
+ const char *errorstr = "<html><body>AFB-Daemon File Not Find file</body></html>";
response = MHD_create_response_from_buffer(strlen(errorstr), (void*)errorstr, MHD_RESPMEM_PERSISTENT);
ret = MHD_queue_response(connection, MHD_HTTP_INTERNAL_SERVER_ERROR, response);
return (MHD_YES);
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) {
// 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