From 3f04367fb8fbcf18e46cb09a766b18f36ffd9602 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Fri, 10 Apr 2015 10:40:48 +0200 Subject: bind: Correctly close sockets and invalidate them. Signed-off-by: Andreas Schneider --- include/libssh/priv.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include/libssh/priv.h') diff --git a/include/libssh/priv.h b/include/libssh/priv.h index e8b50ba0..0c5129c5 100644 --- a/include/libssh/priv.h +++ b/include/libssh/priv.h @@ -109,11 +109,15 @@ struct timeval; int gettimeofday(struct timeval *__p, void *__t); +#define _XCLOSESOCKET closesocket + #else /* _WIN32 */ #include #define PRIdS "zd" +#define _XCLOSESOCKET close + #endif /* _WIN32 */ #include "libssh/libssh.h" @@ -332,5 +336,7 @@ int match_hostname(const char *host, const char *pattern, unsigned int len); #define __VA_NARG__(...) (-1) #endif +#define CLOSE_SOCKET(s) do { if ((s) != SSH_INVALID_SOCKET) { _XCLOSESOCKET(s); (s) = SSH_INVALID_SOCKET;} } while(0) + #endif /* _LIBSSH_PRIV_H */ /* vim: set ts=4 sw=4 et cindent: */ -- cgit v1.2.3