summaryrefslogtreecommitdiffstats
path: root/src/pulsecore/core-util.c
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2007-02-14 12:13:49 +0000
committerPierre Ossman <ossman@cendio.se>2007-02-14 12:13:49 +0000
commitdf47c7b828c02afbabc4d024008fabb07a882397 (patch)
treed289d3dcfca3b95267c818669264c94ae9021e70 /src/pulsecore/core-util.c
parent8bf7943e8e03922de8c4a0990057a6fbf07935c6 (diff)
Add a wrapper around close() to work around Windows' ass backwards way of
handling sockets. git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1429 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src/pulsecore/core-util.c')
-rw-r--r--src/pulsecore/core-util.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index ac1023a0..cc0fb205 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -5,7 +5,7 @@
Copyright 2004-2006 Lennart Poettering
Copyright 2004 Joe Marcus Clarke
- Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
+ Copyright 2006-2007 Pierre Ossman <ossman@cendio.se> for Cendio AB
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
@@ -348,6 +348,26 @@ ssize_t pa_loop_write(int fd, const void*data, size_t size, int *type) {
return ret;
}
+/** Platform independent read function. Necessary since not all
+ * systems treat all file descriptors equal. */
+int pa_close(int fd)
+{
+#ifdef OS_IS_WIN32
+ int ret;
+
+ ret = closesocket(fd);
+ if (ret == 0)
+ return 0;
+
+ if (WSAGetLastError() != WSAENOTSOCK) {
+ errno = WSAGetLastError();
+ return ret;
+ }
+#endif
+
+ return close(fd);
+}
+
/* Print a warning messages in case that the given signal is not
* blocked or trapped */
void pa_check_signal_is_blocked(int sig) {