Move socket error interpretation to utils.h.
[tinc] / src / meta.c
index a56f461..4c52464 100644 (file)
@@ -2,6 +2,7 @@
     meta.c -- handle the meta communication
     Copyright (C) 2000-2009 Guus Sliepen <guus@tinc-vpn.org>,
                   2000-2005 Ivo Timmermans
+                  2006      Scott Lamb <slamb@slamb.org>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -93,15 +94,13 @@ bool flush_meta(connection_t *c) {
                                                   c->name, c->hostname);
                        } else if(errno == EINTR) {
                                continue;
-#ifdef EWOULDBLOCK
-                       } else if(errno == EWOULDBLOCK) {
+                       } else if(sockwouldblock(sockerrno)) {
                                ifdebug(CONNECTIONS) logger(LOG_DEBUG, "Flushing %d bytes to %s (%s) would block",
                                                c->outbuflen, c->name, c->hostname);
                                return true;
-#endif
                        } else {
                                logger(LOG_ERR, "Flushing meta data to %s (%s) failed: %s", c->name,
-                                          c->hostname, strerror(errno));
+                                          c->hostname, sockstrerror(sockerrno));
                        }
 
                        return false;
@@ -148,11 +147,11 @@ bool receive_meta(connection_t *c) {
                if(!lenin || !errno) {
                        ifdebug(CONNECTIONS) logger(LOG_NOTICE, "Connection closed by %s (%s)",
                                           c->name, c->hostname);
-               } else if(errno == EINTR)
+               } else if(sockwouldblock(sockerrno))
                        return true;
                else
                        logger(LOG_ERR, "Metadata socket read error for %s (%s): %s",
-                                  c->name, c->hostname, strerror(errno));
+                                  c->name, c->hostname, sockstrerror(sockerrno));
 
                return false;
        }
@@ -224,7 +223,5 @@ bool receive_meta(connection_t *c) {
                return false;
        }
 
-       c->last_ping_time = now;
-
        return true;
 }