summaryrefslogtreecommitdiff
path: root/src/netops.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <carlos@cmartin.tk>2011-08-19 09:03:19 +0200
committerVicent Marti <tanoku@gmail.com>2011-08-30 19:37:14 +0200
commit74bd343ae83398c7e00c239aea1ff8525dc958a1 (patch)
treeecf99df643631ed691195629b930177c2fb00eb9 /src/netops.c
parentf978b748bb50beb0ccbebc3aa118ad289e4c9cba (diff)
downloadlibgit2-74bd343ae83398c7e00c239aea1ff8525dc958a1.tar.gz
Fix Windows compilation
Sockets on Windows are unsigned, so define a type GIT_SOCKET which is signed or unsigned depending on the platform. Thanks to Em for his patience with this. Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
Diffstat (limited to 'src/netops.c')
-rw-r--r--src/netops.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/netops.c b/src/netops.c
index 8126bcee3..7291ba639 100644
--- a/src/netops.c
+++ b/src/netops.c
@@ -26,6 +26,7 @@
#ifndef _WIN32
# include <sys/types.h>
# include <sys/socket.h>
+# include <sys/select.h>
# include <netdb.h>
#else
# define _WIN32_WINNT 0x0501
@@ -143,3 +144,18 @@ int gitno_send(int s, const char *msg, int len, int flags)
return off;
}
+
+int gitno_select_in(gitno_buffer *buf, long int sec, long int usec)
+{
+ fd_set fds;
+ struct timeval tv;
+
+ tv.tv_sec = sec;
+ tv.tv_usec = usec;
+
+ FD_ZERO(&fds);
+ FD_SET(buf->fd, &fds);
+
+ /* The select(2) interface is silly */
+ return select(buf->fd + 1, &fds, NULL, NULL, &tv);
+}