Skip to content

Commit 04830e8

Browse files
committed
build: Port use of shutdown() on mingw
Even though mingw's <unistd.h> has a definition for SHUT_WR, it is guarded by _POSIX_SOURCE, and does not get enabled in our build setup. We can instead utilize winsock2.h's non-standard names for shutdown(how). We also need to allow for a missing definition of ESHUTDOWN. Fixes: bf8653b ("server: Give client EOF when we are done writing") Fixes: 6a7def7 ("blocksize-policy: Add blocksize-write-disconnect=N parameter")
1 parent b90d47f commit 04830e8

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

common/utils/windows-compat.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* nbdkit
2-
* Copyright (C) 2020 Red Hat Inc.
2+
* Copyright (C) 2020-2022 Red Hat Inc.
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions are
@@ -85,6 +85,12 @@ struct sockaddr_un
8585
#define ESHUTDOWN ECONNABORTED
8686
#endif
8787

88+
/* Windows uses non-standard names for shutdown(how). */
89+
#ifndef SHUT_WR
90+
#define SHUT_WR SD_SEND
91+
#define SHUT_RDWR SD_BOTH
92+
#endif
93+
8894
/* This generated function translates Winsock errors into errno codes. */
8995
extern int translate_winsock_error (const char *fn, int err);
9096

filters/blocksize-policy/policy.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343

4444
#include "ispowerof2.h"
4545
#include "rounding.h"
46+
#include "windows-compat.h"
4647

4748
/* Block size constraints configured on the command line (0 = unset). */
4849
static uint32_t config_minimum;

0 commit comments

Comments
 (0)