OSDN Git Service

avformat/udp: Close the socket after destroying the thread using the socket
authorMichael Niedermayer <michael@niedermayer.cc>
Tue, 24 May 2016 22:59:18 +0000 (00:59 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Tue, 24 May 2016 23:39:23 +0000 (01:39 +0200)
for send() this cannot work and even for recv() it feels very wrong and hackish

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/udp.c

index 58e7498..648efc2 100644 (file)
@@ -1109,7 +1109,6 @@ static int udp_close(URLContext *h)
 
     if (s->is_multicast && (h->flags & AVIO_FLAG_READ))
         udp_leave_multicast_group(s->udp_fd, (struct sockaddr *)&s->dest_addr,(struct sockaddr *)&s->local_addr_storage);
-    closesocket(s->udp_fd);
 #if HAVE_PTHREAD_CANCEL
     if (s->thread_started) {
         int ret;
@@ -1123,6 +1122,7 @@ static int udp_close(URLContext *h)
         pthread_cond_destroy(&s->cond);
     }
 #endif
+    closesocket(s->udp_fd);
     av_fifo_freep(&s->fifo);
     return 0;
 }