Skip to content

Commit

Permalink
build: Port use of shutdown() on mingw
Browse files Browse the repository at this point in the history
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")
  • Loading branch information
ebblake committed Nov 1, 2022
1 parent b90d47f commit 04830e8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion common/utils/windows-compat.h
@@ -1,5 +1,5 @@
/* nbdkit
* Copyright (C) 2020 Red Hat Inc.
* Copyright (C) 2020-2022 Red Hat Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
Expand Down Expand Up @@ -85,6 +85,12 @@ struct sockaddr_un
#define ESHUTDOWN ECONNABORTED
#endif

/* Windows uses non-standard names for shutdown(how). */
#ifndef SHUT_WR
#define SHUT_WR SD_SEND
#define SHUT_RDWR SD_BOTH
#endif

/* This generated function translates Winsock errors into errno codes. */
extern int translate_winsock_error (const char *fn, int err);

Expand Down
1 change: 1 addition & 0 deletions filters/blocksize-policy/policy.c
Expand Up @@ -43,6 +43,7 @@

#include "ispowerof2.h"
#include "rounding.h"
#include "windows-compat.h"

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

0 comments on commit 04830e8

Please sign in to comment.