[pulseaudio-commits] r1429 - in /trunk/src/pulsecore: core-util.c core-util.h iochannel.c pipe.c socket-client.c socket-server.c socket-util.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Wed Feb 14 04:13:50 PST 2007


Author: ossman
Date: Wed Feb 14 13:13:49 2007
New Revision: 1429

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=3D1429&root=3Dpulseaudio&vi=
ew=3Drev
Log:
Add a wrapper around close() to work around Windows' ass backwards way of
handling sockets.

Modified:
    trunk/src/pulsecore/core-util.c
    trunk/src/pulsecore/core-util.h
    trunk/src/pulsecore/iochannel.c
    trunk/src/pulsecore/pipe.c
    trunk/src/pulsecore/socket-client.c
    trunk/src/pulsecore/socket-server.c
    trunk/src/pulsecore/socket-util.c

Modified: trunk/src/pulsecore/core-util.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/pulsecore/core-util.c=
?rev=3D1429&root=3Dpulseaudio&r1=3D1428&r2=3D1429&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/src/pulsecore/core-util.c (original)
+++ trunk/src/pulsecore/core-util.c Wed Feb 14 13:13:49 2007
@@ -5,7 +5,7 @@
 =

   Copyright 2004-2006 Lennart Poettering
   Copyright 2004 Joe Marcus Clarke
-  Copyright 2006 Pierre Ossman <ossman at cendio.se> for Cendio AB
+  Copyright 2006-2007 Pierre Ossman <ossman at 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 @@
     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 =3D closesocket(fd);
+    if (ret =3D=3D 0)
+        return 0;
+
+    if (WSAGetLastError() !=3D WSAENOTSOCK) {
+        errno =3D 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) {

Modified: trunk/src/pulsecore/core-util.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/pulsecore/core-util.h=
?rev=3D1429&root=3Dpulseaudio&r1=3D1428&r2=3D1429&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/src/pulsecore/core-util.h (original)
+++ trunk/src/pulsecore/core-util.h Wed Feb 14 13:13:49 2007
@@ -7,7 +7,7 @@
   This file is part of PulseAudio.
 =

   Copyright 2004-2006 Lennart Poettering
-  Copyright 2006 Pierre Ossman <ossman at cendio.se> for Cendio AB
+  Copyright 2006-2007 Pierre Ossman <ossman at 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
@@ -43,6 +43,8 @@
 ssize_t pa_write(int fd, const void *buf, size_t count, int *type);
 ssize_t pa_loop_read(int fd, void*data, size_t size, int *type);
 ssize_t pa_loop_write(int fd, const void*data, size_t size, int *type);
+
+int pa_close(int fd);
 =

 void pa_check_signal_is_blocked(int sig);
 =


Modified: trunk/src/pulsecore/iochannel.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/pulsecore/iochannel.c=
?rev=3D1429&root=3Dpulseaudio&r1=3D1428&r2=3D1429&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/src/pulsecore/iochannel.c (original)
+++ trunk/src/pulsecore/iochannel.c Wed Feb 14 13:13:49 2007
@@ -4,7 +4,7 @@
   This file is part of PulseAudio.
 =

   Copyright 2004-2006 Lennart Poettering
-  Copyright 2006 Pierre Ossman <ossman at cendio.se> for Cendio AB
+  Copyright 2006-2007 Pierre Ossman <ossman at 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
@@ -174,10 +174,9 @@
 =

     if (!io->no_close) {
         if (io->ifd >=3D 0)
-
-            close(io->ifd);
+            pa_close(io->ifd);
         if (io->ofd >=3D 0 && io->ofd !=3D io->ifd)
-            close(io->ofd);
+            pa_close(io->ofd);
     }
 =

     pa_xfree(io);

Modified: trunk/src/pulsecore/pipe.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/pulsecore/pipe.c?rev=
=3D1429&root=3Dpulseaudio&r1=3D1428&r2=3D1429&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/src/pulsecore/pipe.c (original)
+++ trunk/src/pulsecore/pipe.c Wed Feb 14 13:13:49 2007
@@ -3,7 +3,7 @@
 /***
   This file is part of PulseAudio.
 =

-  Copyright 2006 Pierre Ossman <ossman at cendio.se> for Cendio AB
+  Copyright 2006-2007 Pierre Ossman <ossman at 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 published
@@ -144,17 +144,17 @@
     if ((addr.sin_port !=3D peer.sin_port) || (addr.sin_addr.s_addr !=3D p=
eer.sin_addr.s_addr))
         goto error;
 =

-    close(listener);
+    pa_close(listener);
 =

     return 0;
 =

 error:
 	if (listener >=3D 0)
-		close(listener);
+		pa_close(listener);
 	if (filedes[0] >=3D 0)
-		close(filedes[0]);
+		pa_close(filedes[0]);
 	if (filedes[1] >=3D 0)
-		close(filedes[0]);
+		pa_close(filedes[0]);
 =

 	return -1;
 }

Modified: trunk/src/pulsecore/socket-client.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/pulsecore/socket-clie=
nt.c?rev=3D1429&root=3Dpulseaudio&r1=3D1428&r2=3D1429&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/src/pulsecore/socket-client.c (original)
+++ trunk/src/pulsecore/socket-client.c Wed Feb 14 13:13:49 2007
@@ -4,7 +4,7 @@
   This file is part of PulseAudio.
 =

   Copyright 2004-2006 Lennart Poettering
-  Copyright 2006 Pierre Ossman <ossman at cendio.se> for Cendio AB
+  Copyright 2006-2007 Pierre Ossman <ossman at 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
@@ -163,7 +163,7 @@
 =

 finish:
     if (!io && c->fd >=3D 0)
-        close(c->fd);
+        pa_close(c->fd);
     c->fd =3D -1;
 =

     free_events(c);
@@ -310,7 +310,7 @@
     free_events(c);
 =

     if (c->fd >=3D 0)
-        close(c->fd);
+        pa_close(c->fd);
 =

 #ifdef HAVE_LIBASYNCNS
     if (c->asyncns_query)
@@ -403,7 +403,7 @@
     assert(c);
 =

     if (c->fd >=3D 0) {
-        close(c->fd);
+        pa_close(c->fd);
         c->fd =3D -1;
     }
 =


Modified: trunk/src/pulsecore/socket-server.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/pulsecore/socket-serv=
er.c?rev=3D1429&root=3Dpulseaudio&r1=3D1428&r2=3D1429&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/src/pulsecore/socket-server.c (original)
+++ trunk/src/pulsecore/socket-server.c Wed Feb 14 13:13:49 2007
@@ -4,7 +4,7 @@
   This file is part of PulseAudio.
 =

   Copyright 2004-2006 Lennart Poettering
-  Copyright 2006 Pierre Ossman <ossman at cendio.se> for Cendio AB
+  Copyright 2006-2007 Pierre Ossman <ossman at 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 published
@@ -106,7 +106,7 @@
     pa_fd_set_cloexec(nfd, 1);
 =

     if (!s->on_connection) {
-        close(nfd);
+        pa_close(nfd);
         goto finish;
     }
 =

@@ -119,7 +119,7 @@
         fromhost(&req);
         if (!hosts_access(&req)) {
             pa_log_warn("TCP connection refused by tcpwrap.");
-            close(nfd);
+            pa_close(nfd);
             goto finish;
         }
 =

@@ -216,7 +216,7 @@
 =

 fail:
     if (fd >=3D 0)
-        close(fd);
+        pa_close(fd);
 =

     return NULL;
 }
@@ -275,7 +275,7 @@
 =

 fail:
     if (fd >=3D 0)
-        close(fd);
+        pa_close(fd);
 =

     return NULL;
 }
@@ -331,7 +331,7 @@
 =

 fail:
     if (fd >=3D 0)
-        close(fd);
+        pa_close(fd);
 =

     return NULL;
 }
@@ -398,7 +398,7 @@
         pa_xfree(s->filename);
     }
 =

-    close(s->fd);
+    pa_close(s->fd);
 =

     pa_xfree(s->tcpwrap_service);
 =


Modified: trunk/src/pulsecore/socket-util.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/pulsecore/socket-util=
.c?rev=3D1429&root=3Dpulseaudio&r1=3D1428&r2=3D1429&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/src/pulsecore/socket-util.c (original)
+++ trunk/src/pulsecore/socket-util.c Wed Feb 14 13:13:49 2007
@@ -5,7 +5,7 @@
 =

   Copyright 2004-2006 Lennart Poettering
   Copyright 2004 Joe Marcus Clarke
-  Copyright 2006 Pierre Ossman <ossman at cendio.se> for Cendio AB
+  Copyright 2006-2007 Pierre Ossman <ossman at 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 published
@@ -236,7 +236,7 @@
 =

 finish:
     if (fd >=3D 0)
-        close(fd);
+        pa_close(fd);
 =

     return ret;
 }




More information about the pulseaudio-commits mailing list