aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2016-01-25 10:38:04 +0100
committerJosé Bollo <jose.bollo@iot.bzh>2016-01-25 11:36:15 +0100
commit9b0f0c14da41424fc0ab50cc9a71499dcb307bd0 (patch)
tree7c0b6971b917d7d5368a92ce8e1aa007fb57cd52
parent181efe6b62e3c4fa8293d501719fa5934cb0f59c (diff)
http-svc: refactor of httpdLoop
Reading stdin drives to problems when afb-daemon is launched with its input either closed or connected to /dev/null. Conversely, launching afb-daemon with the option --daemon is not always possible because it really daemonizes itself what forbids to control it or its group directly. Change-Id: I182741226762110809e50d68154f5d29d133303b Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--src/http-svc.c17
-rw-r--r--src/main.c2
2 files changed, 5 insertions, 14 deletions
diff --git a/src/http-svc.c b/src/http-svc.c
index 1eeb2878..3b9db7ad 100644
--- a/src/http-svc.c
+++ b/src/http-svc.c
@@ -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
diff --git a/src/main.c b/src/main.c
index 302d3076..e14dc3a1 100644
--- a/src/main.c
+++ b/src/main.c
@@ -442,7 +442,7 @@ int main(int argc, char *argv[]) {
// open syslog if ever needed
openlog("AGB-log", 0, LOG_DAEMON);
- // -------------- Try to kill any previsou process if asked ---------------------
+ // -------------- Try to kill any previous process if asked ---------------------
if (session->killPrevious) {
pid = readPidFile (session->config); // enforce commandline option
switch (pid) {