Merge branch 'py-reserve'
authorFredrik Tolf <fredrik@dolda2000.com>
Mon, 6 Jan 2014 03:00:02 +0000 (04:00 +0100)
committerFredrik Tolf <fredrik@dolda2000.com>
Mon, 6 Jan 2014 03:00:02 +0000 (04:00 +0100)
lib/cf.c
src/dirplex/dirplex.c
src/patplex.c

index 47db8c2..5a6388e 100644 (file)
--- a/lib/cf.c
+++ b/lib/cf.c
@@ -386,9 +386,10 @@ static int stdhandle(struct child *ch, struct hthead *req, int fd, void (*chinit
                freeca(args);
                if(!sendreq2(sd->fd, req, fd, MSG_NOSIGNAL | MSG_DONTWAIT))
                    return(0);
+               serr = errno;
            }
-           flog(LOG_ERR, "could not pass on request to child %s: %s", ch->name, strerror(serr));
            if(serr != EAGAIN) {
+               flog(LOG_ERR, "could not pass on request to child %s: %s", ch->name, strerror(serr));
                close(sd->fd);
                sd->fd = -1;
            }
index d687957..f6002f3 100644 (file)
@@ -55,6 +55,14 @@ static void chinit(void *idata)
     }
 }
 
+static void childerror(struct hthead *req, int fd)
+{
+    if(errno == EAGAIN)
+       simpleerror(fd, 500, "Server Error", "The request handler is overloaded.");
+    else
+       simpleerror(fd, 500, "Server Error", "The request handler crashed.");
+}
+
 static void handle(struct hthead *req, int fd, char *path, struct pattern *pat)
 {
     struct child *ch;
@@ -91,7 +99,7 @@ static void handle(struct hthead *req, int fd, char *path, struct pattern *pat)
        }
        headappheader(req, "X-Ash-File", path);
        if(childhandle(ch, req, fd, chinit, twd))
-           simpleerror(fd, 500, "Server Error", "The request handler crashed.");
+           childerror(req, fd);
     }
 }
 
@@ -104,7 +112,7 @@ static void handle404(struct hthead *req, int fd, char *path)
     tmp = sstrdup(path);
     ch = findchild(tmp, ".notfound", &ccf);
     if(childhandle(ch, req, fd, chinit, ccf?ccf->path:NULL))
-       simpleerror(fd, 500, "Server Error", "The request handler crashed.");
+       childerror(req, fd);
     free(tmp);
 }
 
@@ -257,7 +265,7 @@ static int checkdir(struct hthead *req, int fd, char *path, char *rest)
            rest++;
        replrest(req, rest);
        if(childhandle(ch, req, fd, chinit, ccf?ccf->path:NULL))
-           simpleerror(fd, 500, "Server Error", "The request handler crashed.");
+           childerror(req, fd);
        return(1);
     }
     return(0);
index 692d480..d0e2dad 100644 (file)
@@ -472,6 +472,14 @@ static struct pattern *findmatch(struct config *cf, struct hthead *req, int tryd
     return(NULL);
 }
 
+static void childerror(struct hthead *req, int fd)
+{
+    if(errno == EAGAIN)
+       simpleerror(fd, 500, "Server Error", "The request handler is overloaded.");
+    else
+       simpleerror(fd, 500, "Server Error", "The request handler crashed.");
+}
+
 static void serve(struct hthead *req, int fd)
 {
     struct pattern *pat;
@@ -511,7 +519,7 @@ static void serve(struct hthead *req, int fd)
        headappheader(req, head->name, head->value);
     }
     if(childhandle(ch, req, fd, NULL, NULL))
-       simpleerror(fd, 500, "Server Error", "The request handler crashed.");
+       childerror(req, fd);
 }
 
 static void reloadconf(char *nm)