changeset 15421:ae5e1b9e3c92

fix segfaults caused by socket and file descriptor mismatches on windows
author faust3
date Thu, 12 May 2005 22:07:11 +0000
parents f3cf481bbcda
children 9ac14c8b99b3
files libmpdemux/stream.c
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/stream.c	Thu May 12 17:35:58 2005 +0000
+++ b/libmpdemux/stream.c	Thu May 12 22:07:11 2005 +0000
@@ -444,7 +444,14 @@
   default:
     if(s->close) s->close(s);
   }
-  if(s->fd>0) closesocket(s->fd);
+  if(s->fd>0){
+    /* on unix we define closesocket to close
+       on windows however we have to distinguish between
+       network socket and file */
+    if(s->url && strstr(s->url,"://"))
+      closesocket(s->fd);
+    else close(s->fd);
+  }
 #ifdef HAVE_WINSOCK2
   mp_msg(MSGT_STREAM,MSGL_V,"WINSOCK2 uninit\n");
   WSACleanup(); // there might be a better place for this (-> later)