From 4f9bbe376939daf78d80e3b977e02a50a40c370f Mon Sep 17 00:00:00 2001 From: sammirata Date: Tue, 4 Oct 2016 18:51:45 -0400 Subject: [PATCH] Do not require exclusive bind of udp sockets (#154) --- AUTHORS | 1 + CONTRIBUTORS | 1 + packager/media/file/udp_file_posix.cc | 8 ++++++++ 3 files changed, 10 insertions(+) diff --git a/AUTHORS b/AUTHORS index 4818cd20d3..41f3a0f641 100644 --- a/AUTHORS +++ b/AUTHORS @@ -17,4 +17,5 @@ Anders Hasselqvist Google Inc. <*@google.com> Leandro Moreira Philo Inc. <*@philo.com> +Sergio Ammirata The Chromium Authors <*@chromium.org> diff --git a/CONTRIBUTORS b/CONTRIBUTORS index fabb1ab824..4543eca591 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -30,4 +30,5 @@ Joey Parrish Kongqun Yang Leandro Moreira Rintaro Kuroiwa +Sergio Ammirata Thomas Inskip diff --git a/packager/media/file/udp_file_posix.cc b/packager/media/file/udp_file_posix.cc index e8354e91f4..48a62ac64f 100644 --- a/packager/media/file/udp_file_posix.cc +++ b/packager/media/file/udp_file_posix.cc @@ -187,6 +187,14 @@ bool UdpFile::Open() { local_sock_addr.sin_family = AF_INET; local_sock_addr.sin_port = htons(dest_port); local_sock_addr.sin_addr.s_addr = htonl(dest_addr); + // We do not need to require exclusive bind of udp sockets + const int optval = 1; + if (setsockopt(new_socket.get(), SOL_SOCKET, SO_REUSEADDR, &optval, + sizeof(optval)) < 0) { + LOG(ERROR) + << "Could not apply the SO_REUSEADDR property to the UDP socket"; + return false; + } if (bind(new_socket.get(), reinterpret_cast(&local_sock_addr), sizeof(local_sock_addr))) {