]> diplodocus.org Git - nmh/blobdiff - test/server.c
sbr/mf.c: Simplify logic, ditching endless for-loops and switch.
[nmh] / test / server.c
index 13f3c873f6c12bca8a739d4772850de7635182c4..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)
 {
@@ -116,6 +120,8 @@ serve(const char *pidfn, const char *port)
                exit(1);
        }
 
+       freeaddrinfo(res);
+
        if (listen(l, 1) == -1) {
                fprintf(stderr, "Unable to listen on socket: %s\n",
                        strerror(errno));
@@ -215,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");
        }
 }