summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Roche <xroche@users.noreply.github.com>2013-04-14 13:43:12 +0000
committerXavier Roche <xroche@users.noreply.github.com>2013-04-14 13:43:12 +0000
commitde3815873a418692db7f20caf373cd7b64c60ea3 (patch)
tree647bbbe3345f929505f3e227e4abd7a249a2b610
parent67b29c973b8b53031435f45b90ff3369be8536ed (diff)
Print "error closing socket" error messages if the socket can not be closed.
-rw-r--r--src/htslib.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/htslib.c b/src/htslib.c
index a416dcd..51ea004 100644
--- a/src/htslib.c
+++ b/src/htslib.c
@@ -2479,9 +2479,15 @@ HTS_INLINE void deletesoc(T_SOC soc) {
DEBUG_W("close %d\n" _ (int) soc);
#endif
#ifdef _WIN32
- closesocket(soc);
+ if (closesocket(soc) != 0) {
+ int err = WSAGetLastError();
+ fprintf(stderr, "* error closing socket %d: %s\n", soc, strerror(err));
+ }
#else
- close(soc);
+ if (close(soc) != 0) {
+ const int err = errno;
+ fprintf(stderr, "* error closing socket %d: %s\n", soc, strerror(err));
+ }
#endif
#if HTS_WIDE_DEBUG
DEBUG_W(".. done\n");