summaryrefslogtreecommitdiff
path: root/src/app.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/app.c')
-rw-r--r--src/app.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/app.c b/src/app.c
index 0d3afda..3303472 100644
--- a/src/app.c
+++ b/src/app.c
@@ -72,22 +72,25 @@ static fcgy_front *front_create(fcgy_app *app, fcgy_front_type t, const char *ad
}
-/* TODO: Better error reporting */
-static int front_bind(fcgy_front *f) {
+static int front_bind(fcgy_front *f, char *err, size_t errlen) {
switch(f->type) {
case FCGY_FRONT_UNIX: {
struct sockaddr_un addr;
addr.sun_family = AF_UNIX;
int r = snprintf(addr.sun_path, sizeof(addr.sun_path), "%s", f->addr);
- if(r < 0 || r >= (int)sizeof(addr.sun_path))
+ if(r < 0 || r >= (int)sizeof(addr.sun_path)) {
+ snprintf(err, errlen, "invalid socket path");
return -1;
+ }
f->fd = util_serversock(AF_UNIX, &addr, sizeof(addr), FCGY_CLOEXEC|FCGY_NONBLOCK);
- if(f->fd < 0)
+ if(f->fd < 0) {
+ snprintf(err, errlen, "can't bind socket: %s", strerror(errno));
return -1;
- break;
}
+ }
+ break;
case FCGY_FRONT_TCP:
case FCGY_FRONT_STDIO:
@@ -157,13 +160,15 @@ int app_config(fcgy_app *app, fcgy_config_name name, const char *val, char *err,
}
-/* TODO: Error reporting */
-int app_bind(fcgy_app *app) {
+int app_bind(fcgy_app *app, char *err, size_t errlen) {
fcgy_front *f;
- int n = 0;
- for(f=app->fronts; n == 0 && f; f=f->next)
- n = front_bind(f);
- return n;
+ char ebuff[256];
+ for(f=app->fronts; f; f=f->next)
+ if(front_bind(f, ebuff, sizeof(ebuff)) < 0) {
+ snprintf(err, errlen, "%s: %s", f->addr, ebuff);
+ return -1;
+ }
+ return 0;
}