Dolda2000 GitWeb
/
ashd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
dirplex, patplex: Emit more helpful error message on EAGAIN from child.
[ashd.git]
/
src
/
dirplex
/
dirplex.c
diff --git
a/src/dirplex/dirplex.c
b/src/dirplex/dirplex.c
index
baf24fa
..
f6002f3
100644
(file)
--- a/
src/dirplex/dirplex.c
+++ b/
src/dirplex/dirplex.c
@@
-55,12
+55,27
@@
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;
struct config *ccf;
static void handle(struct hthead *req, int fd, char *path, struct pattern *pat)
{
struct child *ch;
struct config *ccf;
+ struct headmod *head;
char *twd;
char *twd;
+ for(head = pat->headers; head != NULL; head = head->next) {
+ headrmheader(req, head->name);
+ headappheader(req, head->name, head->value);
+ }
+ if(!strncmp(path, "./", 2) && path[2])
+ path += 2;
if(pat->fchild) {
headappheader(req, "X-Ash-File", path);
stdforkserve(pat->fchild, req, fd, NULL, NULL);
if(pat->fchild) {
headappheader(req, "X-Ash-File", path);
stdforkserve(pat->fchild, req, fd, NULL, NULL);
@@
-84,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))
}
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
);
}
}
}
}
@@
-97,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))
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);
}
free(tmp);
}
@@
-237,7
+252,7
@@
static int checkdir(struct hthead *req, int fd, char *path, char *rest)
struct child *ch;
cf = getconfig(path);
struct child *ch;
cf = getconfig(path);
- if(
cf->capture != NULL
) {
+ if(
(cf->capture != NULL) && (cf->caproot || !cf->path || strcmp(cf->path, "."))
) {
cpath = sprintf2("%s/", path);
if((ch = findchild(cpath, cf->capture, &ccf)) == NULL) {
free(cpath);
cpath = sprintf2("%s/", path);
if((ch = findchild(cpath, cf->capture, &ccf)) == NULL) {
free(cpath);
@@
-250,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))
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);
return(1);
}
return(0);
@@
-313,10
+328,12
@@
static void serve(struct hthead *req, int fd)
static void chldhandler(int sig)
{
pid_t pid;
static void chldhandler(int sig)
{
pid_t pid;
+ int st;
- do {
- pid = waitpid(-1, NULL, WNOHANG);
- } while(pid > 0);
+ while((pid = waitpid(-1, &st, WNOHANG)) > 0) {
+ if(WCOREDUMP(st))
+ flog(LOG_WARNING, "child process %i dumped core", pid);
+ }
}
static void sighandler(int sig)
}
static void sighandler(int sig)