Skip to content

Commit a794179

Browse files
j6tgitster
authored andcommitted
Windows: add a wrapper for the shutdown() system call
Even though Windows's socket functions look like their POSIX counter parts, they do not operate on file descriptors, but on "socket objects". To bring the functions in line with POSIX, we have proxy functions that wrap and unwrap the socket objects in file descriptors using open_osfhandle and get_osfhandle. But shutdown() was not proxied, yet. Fix this. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 4fec830 commit a794179

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

compat/mingw.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,6 +1219,13 @@ int mingw_setsockopt(int sockfd, int lvl, int optname, void *optval, int optlen)
12191219
return setsockopt(s, lvl, optname, (const char*)optval, optlen);
12201220
}
12211221

1222+
#undef shutdown
1223+
int mingw_shutdown(int sockfd, int how)
1224+
{
1225+
SOCKET s = (SOCKET)_get_osfhandle(sockfd);
1226+
return shutdown(s, how);
1227+
}
1228+
12221229
#undef listen
12231230
int mingw_listen(int sockfd, int backlog)
12241231
{

compat/mingw.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ int mingw_bind(int sockfd, struct sockaddr *sa, size_t sz);
219219
int mingw_setsockopt(int sockfd, int lvl, int optname, void *optval, int optlen);
220220
#define setsockopt mingw_setsockopt
221221

222+
int mingw_shutdown(int sockfd, int how);
223+
#define shutdown mingw_shutdown
224+
222225
int mingw_listen(int sockfd, int backlog);
223226
#define listen mingw_listen
224227

0 commit comments

Comments
 (0)