Merge commit '9835abb6d63fb07613994ae90e72fef758149408'
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 5 Jun 2013 09:56:56 +0000 (11:56 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 5 Jun 2013 09:56:56 +0000 (11:56 +0200)
* commit '9835abb6d63fb07613994ae90e72fef758149408':
  network: uniform ff_listen_bind and ff_listen_connect

Conflicts:
libavformat/network.c
libavformat/tcp.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavformat/network.c
libavformat/network.h
libavformat/tcp.c

@@@ -214,8 -189,29 +214,29 @@@ int ff_is_multicast_address(struct sock
      return 0;
  }
  
 -    } while (timeout < 0 || runs-- > 0);
+ static int ff_poll_interrupt(struct pollfd *p, nfds_t nfds, int timeout,
+                              AVIOInterruptCB *cb)
+ {
+     int runs = timeout / POLLING_TIME;
+     int ret = 0;
+     do {
+         if (ff_check_interrupt(cb))
+             return AVERROR_EXIT;
+         ret = poll(p, nfds, POLLING_TIME);
+         if (ret != 0)
+             break;
++    } while (timeout <= 0 || runs-- > 0);
+     if (!ret)
+         return AVERROR(ETIMEDOUT);
+     if (ret < 0)
+         return AVERROR(errno);
+     return ret;
+ }
  int ff_listen_bind(int fd, const struct sockaddr *addr,
-                    socklen_t addrlen, int timeout)
+                    socklen_t addrlen, int timeout, URLContext *h)
  {
      int ret;
      int reuse = 1;
  }
  
  int ff_listen_connect(int fd, const struct sockaddr *addr,
-                       socklen_t addrlen, int rw_timeout, URLContext *h)
+                       socklen_t addrlen, int timeout, URLContext *h)
  {
      struct pollfd p = {fd, POLLOUT, 0};
 +    int64_t wait_started;
      int ret;
      socklen_t optlen;
  
Simple merge
@@@ -113,15 -90,15 +113,15 @@@ static int tcp_open(URLContext *h, cons
          goto fail;
      }
  
 -    if (listen_socket) {
 +    if (s->listen) {
          if ((fd = ff_listen_bind(fd, cur_ai->ai_addr, cur_ai->ai_addrlen,
-                                  s->listen_timeout)) < 0) {
 -                                 listen_timeout, h)) < 0) {
++                                 s->listen_timeout, h)) < 0) {
              ret = fd;
              goto fail1;
          }
      } else {
          if ((ret = ff_listen_connect(fd, cur_ai->ai_addr, cur_ai->ai_addrlen,
-                                      h->rw_timeout, h)) < 0) {
 -                                     timeout * 100, h)) < 0) {
++                                     h->rw_timeout / 1000, h)) < 0) {
  
              if (ret == AVERROR_EXIT)
                  goto fail1;