ithewei 6 éve
szülő
commit
e1e00d13ce
3 módosított fájl, 11 hozzáadás és 1 törlés
  1. 9 0
      base/hdef.h
  2. 1 0
      base/hsocket.h
  3. 1 1
      http/client/http_client.cpp

+ 9 - 0
base/hdef.h

@@ -111,6 +111,15 @@ typedef void (*procedure_t)(void* userdata);
 #define LIMIT(lower, v, upper) ((v) < (lower) ? (lower) : (v) > (upper) ? (upper) : (v))
 #endif
 
+#ifndef SWAP
+#define SWAP(type, a, b) \
+    do {\
+        type x = a;\
+        a = b;\
+        b = x;\
+    } while(0)
+#endif
+
 #ifndef BITSET
 #define BITSET(p, n) (*(p) |= (1u << (n)))
 #endif

+ 1 - 0
base/hsocket.h

@@ -67,6 +67,7 @@ static inline int nonblocking(int sockfd) {
 #define blocking(s)     fcntl(s, F_SETFL, fcntl(s, F_GETFL) & ~O_NONBLOCK)
 #define nonblocking(s)  fcntl(s, F_SETFL, fcntl(s, F_GETFL) |  O_NONBLOCK)
 typedef int         SOCKET;
+#define INVALID_SOCKET  -1
 #define closesocket close
 #endif
 

+ 1 - 1
http/client/http_client.cpp

@@ -335,7 +335,7 @@ static int __http_session_send(http_session_t* hss, HttpRequest* req, HttpRespon
     // connect -> send -> recv -> http_parser
     int err = 0;
     int timeout = hss->timeout;
-    SOCKET connfd = hss->fd;
+    int connfd = hss->fd;
 
     // use_tls ?
     int use_tls = hss->use_tls;