Browse Source

Fix error handling for unix-socket-connect test

git-svn-id: svn://svn.lighttpd.net/spawn-fcgi/trunk@15 4a9f3682-ca7b-49a8-9a55-ba4640e46f83
master
Stefan Bühler 13 years ago
parent
commit
210b3b54f6
  1. 1
      NEWS
  2. 19
      src/spawn-fcgi.c

1
NEWS

@ -12,3 +12,4 @@ NEWS
* Only disconnect from terminal in fork mode (keep stderr/stdout open in nofork mode)
* Allow numerical user and group ids for -u/-g (fixes #1141)
* Ignore pid-file option in no-fork mode (instead of producing empty file)
* Fix error handling for unix-socket-connect test

19
src/spawn-fcgi.c

@ -95,20 +95,23 @@ static int fcgi_spawn_connection(char *appPath, char **appArgv, char *addr, unsi
return -1;
}
if (-1 != connect(fcgi_fd, fcgi_addr, servlen)) {
if (0 == connect(fcgi_fd, fcgi_addr, servlen)) {
fprintf(stderr, "spawn-fcgi: socket is already in use, can't spawn\n");
close(fcgi_fd);
return -1;
}
/* cleanup previous socket if it exists */
if (-1 == unlink(unixsocket)) {
switch (errno) {
case EADDRINUSE:
fprintf(stderr, "spawn-fcgi: socket is already in use, can't spawn\n");
case ENOENT:
break;
default:
fprintf(stderr, "spawn-fcgi: connect failed: %s\n", strerror(errno));
break;
fprintf(stderr, "spawn-fcgi: removing old socket failed: %s\n", strerror(errno));
return -1;
}
return -1;
}
/* cleanup previous socket if it exists */
unlink(unixsocket);
close(fcgi_fd);
} else {
memset(&fcgi_addr_in, 0, sizeof(fcgi_addr_in));

Loading…
Cancel
Save