* Handle ECONNRESET from the client. Also, don't abort() if there are

unexpected conditions in the SIGPOLL handler, since that messes up
  the Berkeley DB environment (which a client must never be able to
  trigger).
This commit is contained in:
Eelco Dolstra 2007-03-28 15:46:21 +00:00
parent efd31139df
commit 17b506c0c7

View file

@ -79,8 +79,11 @@ static bool isFarSideClosed(int socket)
socket as readable because there is actual input or because socket as readable because there is actual input or because
we've reached EOF (i.e., a read of size 0 is available). */ we've reached EOF (i.e., a read of size 0 is available). */
char c; char c;
if (read(socket, &c, 1) != 0) int rd;
if ((rd = read(socket, &c, 1)) > 0)
throw Error("EOF expected (protocol error?)"); throw Error("EOF expected (protocol error?)");
else if (rd == -1 && errno != ECONNRESET)
throw SysError("expected connection reset or EOF");
return true; return true;
} }
@ -109,7 +112,8 @@ static void sigPollHandler(int sigNo)
_isInterrupted = 1; _isInterrupted = 1;
blockInt = 1; blockInt = 1;
canSendStderr = false; canSendStderr = false;
write(STDERR_FILENO, "SIGPOLL\n", 8); string s = "SIGPOLL\n";
write(STDERR_FILENO, s.c_str(), s.size());
} }
} else { } else {
string s = "spurious SIGPOLL\n"; string s = "spurious SIGPOLL\n";
@ -118,8 +122,9 @@ static void sigPollHandler(int sigNo)
} }
catch (Error & e) { catch (Error & e) {
/* Shouldn't happen. */ /* Shouldn't happen. */
write(STDERR_FILENO, e.msg().c_str(), e.msg().size()); string s = "impossible: " + e.msg() + '\n';
abort(); write(STDERR_FILENO, s.c_str(), s.size());
throw;
} }
} }