From cb79bec28b6a8715d936c7877ea4a0f7543317d9 Mon Sep 17 00:00:00 2001
From: hyc <hyc@400ebc74-4327-4243-bc38-086b20814532>
Date: Wed, 6 Jan 2010 00:36:40 +0000
Subject: [PATCH] Don't try to close server->socket multiple times

git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@193 400ebc74-4327-4243-bc38-086b20814532
---
 rtmpsuck.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/rtmpsuck.c b/rtmpsuck.c
index 6248024..523e760 100644
--- a/rtmpsuck.c
+++ b/rtmpsuck.c
@@ -1000,6 +1000,8 @@ stopStreaming(STREAMING_SERVER * server)
 
   if (server->state != STREAMING_STOPPED)
     {
+      int fd = server->socket;
+      server->socket = 0;
       if (server->state == STREAMING_IN_PROGRESS)
 	{
 	  server->state = STREAMING_STOPPING;
@@ -1009,7 +1011,7 @@ stopStreaming(STREAMING_SERVER * server)
 	    msleep(1);
 	}
 
-      if (closesocket(server->socket))
+      if (fd && closesocket(fd))
 	Log(LOGERROR, "%s: Failed to close listening socket, error %d",
 	    GetSockError());
 
-- 
2.40.0