]> granicus.if.org Git - pdns/commitdiff
simple changes, gettimeofday -> Utility::gettimeofday etc
authorBert Hubert <bert.hubert@netherlabs.nl>
Sat, 29 Apr 2006 16:50:15 +0000 (16:50 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Sat, 29 Apr 2006 16:50:15 +0000 (16:50 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@795 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/selectmplexer.cc
pdns/sstuff.hh
pdns/syncres.hh

index a860c51d9454c9d8963e7cb62fb4e670b32a8b5a..be330ce3c157e9e7a822bc515590c6969b7393f8 100644 (file)
@@ -5,6 +5,7 @@
 #include "misc.hh"
 #include <boost/lexical_cast.hpp>
 #include "syncres.hh"
+#include "utility.hh" 
 
 using namespace boost;
 using namespace std;
@@ -64,7 +65,7 @@ int SelectFDMultiplexer::run(struct timeval* now)
   
   struct timeval tv={0,500000};
   int ret=select(fdmax + 1, &readfds, &writefds, 0, &tv);
-  gettimeofday(now, 0);
+  Utility::gettimeofday(now, 0);
   
   if(ret < 0 && errno!=EINTR)
     throw FDMultiplexerException("select returned error: "+stringerror());
index 636ed28c8a642e3f7bd945fb0c29250876f97fa7..0cdfa50e0bd0112686683fa0dec0a4da258145e8 100755 (executable)
@@ -7,10 +7,12 @@
 #include <errno.h>
 #include <sys/types.h>
 #include <unistd.h>
+#ifndef WIN32
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <sys/select.h>
+#endif
 #include <fcntl.h>
 #include <stdexcept>
 #include <boost/shared_ptr.hpp>
@@ -44,7 +46,7 @@ public:
   IPAddress(const string &remote)
   {
     struct in_addr addr;
-    if(!inet_aton(remote.c_str(), &addr))
+    if(!Utility::inet_aton(remote.c_str(), &addr))
       throw NetworkError("Could not convert '"+remote+"' to an IP address");
     byte=addr.s_addr;
   }
@@ -131,9 +133,7 @@ public:
   //! Set the socket to non-blocking
   void setNonBlocking()
   {
-    int flags=fcntl(d_socket,F_GETFL,0);    
-    if(flags<0 || fcntl(d_socket, F_SETFL,flags|O_NONBLOCK) <0)
-      throw NetworkError("Setting socket to nonblocking: "+string(strerror(errno)));
+    Utility::setNonBlocking(d_socket);
   }
 
   //! Bind the socket to a specified endpoint
index 5bed103aa2d38bc6cd920e58b077cc7cb36d37de..c937e26d4327d6652e23512cff3f6c5bfe388f12 100644 (file)
@@ -115,7 +115,7 @@ public:
       return *tv;
     else {
       struct timeval ret;
-      gettimeofday(&ret, 0);
+      Utility::gettimeofday(&ret, 0);
       return ret;
     }
   }
@@ -163,7 +163,7 @@ class PulseRate
 public:
   PulseRate() :  d_val(0.0) 
   {
-    gettimeofday(&d_last, 0);
+    Utility::gettimeofday(&d_last, 0);
   }
 
   PulseRate(const PulseRate& orig) : d_last(orig.d_last), d_val(orig.d_val)