diff options
| author | Carlos Martín Nieto <carlos@cmartin.tk> | 2011-09-30 23:48:27 +0200 |
|---|---|---|
| committer | Carlos Martín Nieto <carlos@cmartin.tk> | 2011-10-01 00:41:09 +0200 |
| commit | bad53552e539e58b76c4fcf4902686534f8a2678 (patch) | |
| tree | 33eee462cf8d8e6ab4a4f366bc5c3378d33d1e18 /src/netops.c | |
| parent | a28889198cf9565944aa0ff983459c6bf6eec311 (diff) | |
| download | libgit2-bad53552e539e58b76c4fcf4902686534f8a2678.tar.gz | |
netops: abstract away socket closing
Winsock wants us to use closesocket() instead of close(), so introduce
the gitno_close function, which does the right thing.
Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
Diffstat (limited to 'src/netops.c')
| -rw-r--r-- | src/netops.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/netops.c b/src/netops.c index c8fe37645..7d8a7b28c 100644 --- a/src/netops.c +++ b/src/netops.c @@ -138,6 +138,18 @@ int gitno_send(GIT_SOCKET s, const char *msg, size_t len, int flags) return off; } +#ifdef GIT_WIN32 +int gitno_close(GIT_SOCKET s) +{ + return closesocket(s) == SOCKET_ERROR ? -1 : 0; +} +#else +int gitno_close(GIT_SOCKET s) +{ + return close(s); +} +#endif + int gitno_select_in(gitno_buffer *buf, long int sec, long int usec) { fd_set fds; |
