udp: Print an error message if bind fails

Message ID 1331149255-44263-1-git-send-email-martin@martin.st
State Committed
Headers show

Commit Message

Martin Storsjö March 7, 2012, 7:40 p.m.
---
 libavformat/udp.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

Comments

Ronald Bultje March 7, 2012, 7:48 p.m. | #1
Hi,

On Wed, Mar 7, 2012 at 11:40 AM, Martin Storsjö <martin@martin.st> wrote:
> ---
>  libavformat/udp.c |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/libavformat/udp.c b/libavformat/udp.c
> index 8bb63c6..0a13f67 100644
> --- a/libavformat/udp.c
> +++ b/libavformat/udp.c
> @@ -387,8 +387,10 @@ static int udp_open(URLContext *h, const char *uri, int flags)
>     }
>     /* bind to the local address if not multicast or if the multicast
>      * bind failed */
> -    if (bind_ret < 0 && bind(udp_fd,(struct sockaddr *)&my_addr, len) < 0)
> +    if (bind_ret < 0 && bind(udp_fd,(struct sockaddr *)&my_addr, len) < 0) {
> +        av_log(h, AV_LOG_ERROR, "bind: %s\n", strerror(errno));
>         goto fail;
> +    }

OK. (That "bind" could potentially be extended to "bind failed" or so?)

Ronald
Martin Storsjö March 7, 2012, 7:55 p.m. | #2
On Wed, 7 Mar 2012, Ronald S. Bultje wrote:

> Hi,
>
> On Wed, Mar 7, 2012 at 11:40 AM, Martin Storsjö <martin@martin.st> wrote:
>> ---
>>  libavformat/udp.c |    4 +++-
>>  1 files changed, 3 insertions(+), 1 deletions(-)
>>
>> diff --git a/libavformat/udp.c b/libavformat/udp.c
>> index 8bb63c6..0a13f67 100644
>> --- a/libavformat/udp.c
>> +++ b/libavformat/udp.c
>> @@ -387,8 +387,10 @@ static int udp_open(URLContext *h, const char *uri, int flags)
>>     }
>>     /* bind to the local address if not multicast or if the multicast
>>      * bind failed */
>> -    if (bind_ret < 0 && bind(udp_fd,(struct sockaddr *)&my_addr, len) < 0)
>> +    if (bind_ret < 0 && bind(udp_fd,(struct sockaddr *)&my_addr, len) < 0) {
>> +        av_log(h, AV_LOG_ERROR, "bind: %s\n", strerror(errno));
>>         goto fail;
>> +    }
>
> OK. (That "bind" could potentially be extended to "bind failed" or so?)

Good point. Pushed with that fixed.

// Martin

Patch

diff --git a/libavformat/udp.c b/libavformat/udp.c
index 8bb63c6..0a13f67 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -387,8 +387,10 @@  static int udp_open(URLContext *h, const char *uri, int flags)
     }
     /* bind to the local address if not multicast or if the multicast
      * bind failed */
-    if (bind_ret < 0 && bind(udp_fd,(struct sockaddr *)&my_addr, len) < 0)
+    if (bind_ret < 0 && bind(udp_fd,(struct sockaddr *)&my_addr, len) < 0) {
+        av_log(h, AV_LOG_ERROR, "bind: %s\n", strerror(errno));
         goto fail;
+    }
 
     len = sizeof(my_addr);
     getsockname(udp_fd, (struct sockaddr *)&my_addr, &len);