]> diplodocus.org Git - nmh/commitdiff
Under some circumstances, some version of MacOS X can return EPROTOTYPE
authorKen Hornstein <kenh@pobox.com>
Tue, 6 Sep 2016 19:32:28 +0000 (15:32 -0400)
committerKen Hornstein <kenh@pobox.com>
Tue, 6 Sep 2016 19:32:28 +0000 (15:32 -0400)
if you try to write to a connection that is being torn down.  Handle
that case.

test/server.c

index 5d207141176cc73732d77f86d283e71d9211cfeb..2c2f5c634048c1aa2ecfcce7abb55f18108167b6 100644 (file)
@@ -25,6 +25,10 @@ static const char *PIDFN = NULL;
 static void killpidfile(void);
 static void handleterm(int);
 
+#ifndef EPROTOTYPE
+#define EPROTOTYPE 0
+#endif
+
 static int
 try_bind(int socket, const struct sockaddr *address, socklen_t len)
 {
@@ -217,9 +221,11 @@ putcrlf(int socket, char *data)
        iov[1].iov_len = 2;
 
        /* ECONNRESET just means the client already closed its end */
+       /* MacOS X can also return EPROTOTYPE (!) here sometimes */
        /* XXX is it useful to log errors here at all? */
-       if (writev(socket, iov, 2) < 0 && errno != ECONNRESET) {
-           perror ("writev");
+       if (writev(socket, iov, 2) < 0 && errno != ECONNRESET &&
+           errno != EPROTOTYPE) {
+           perror ("server writev");
        }
 }