-/*----------------------------------------------------------
- | writePidFile
- | write a file in /var/run/AFB with pid
- +--------------------------------------------------------- */
-static int writePidFile (AFB_config *config, int pid) {
- FILE *file;
-
- // if no pid file configure just return
- if (config->pidfile == NULL) return 0;
-
- // open pid file in write mode
- file = fopen(config->pidfile,"w");
- if (file == NULL) {
- fprintf (stderr,"%s ERR:writePidFile fail to open [%s]\n",configTime(), config->pidfile);
- return -1;
- }
-
- // write pid in file and close
- fprintf (file, "%d\n", pid);
- fclose (file);
- return 0;
-}
-
-/*----------------------------------------------------------
- | readPidFile
- | read file in /var/run/AFB with pid
- +--------------------------------------------------------- */
-static int readPidFile (AFB_config *config) {
- int pid;
- FILE *file;
- int status;
-
- if (config->pidfile == NULL) return -1;
-
- // open pid file in write mode
- file = fopen(config->pidfile,"r");
- if (file == NULL) {
- fprintf (stderr,"%s ERR:readPidFile fail to open [%s]\n",configTime(), config->pidfile);
- return -1;
- }
-
- // write pid in file and close
- status = fscanf (file, "%d\n", &pid);
- fclose (file);
-
- // never kill pid 0
- if (status != 1) return -1;
-
- return (pid);
-}
-
-/*----------------------------------------------------------
- | closeSession
- | try to close everything before leaving
- +--------------------------------------------------------- */
-static void closeSession (AFB_session *session) {
-
-
-}
-
-/*----------------------------------------------------------
- | listenLoop
- | Main listening HTTP loop
- +--------------------------------------------------------- */
-static void listenLoop (AFB_session *session) {
- AFB_error err;
-
- if (signal (SIGABRT, signalQuit) == SIG_ERR) {
- fprintf (stderr, "%s ERR: main fail to install Signal handler\n", configTime());
- return;
- }
-
- // ------ Start httpd server
- if (session->config->httpdPort > 0) {
-
- err = httpdStart (session);
- if (err != AFB_SUCCESS) return;
-
- // infinite loop
- httpdLoop(session);
-
- fprintf (stderr, "hoops returned from infinite loop [report bug]\n");
- }
-}
-