]> git.proxmox.com Git - mirror_frr.git/commitdiff
Merge remote-tracking branch 'origin/stable/3.0'
authorDonald Sharp <sharpd@cumulusnetworks.com>
Mon, 8 May 2017 20:51:21 +0000 (16:51 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Mon, 8 May 2017 20:51:21 +0000 (16:51 -0400)
12 files changed:
1  2 
bgpd/bgp_vty.c
configure.ac
doc/Building_FRR_on_Ubuntu1604.md
lib/thread.c
lib/thread.h
ospfd/ospf_vty.c
pimd/pim_cmd.c
pimd/pim_iface.c
pimd/pim_rp.c
pimd/pim_vty.c
pimd/pim_zebra.c
zebra/interface.c

diff --cc bgpd/bgp_vty.c
Simple merge
diff --cc configure.ac
Simple merge
Simple merge
diff --cc lib/thread.c
index 74d498baf8e89d3c973d59e59711e8ac11922bd0,34802fcedd2477c11b7e47c2505ede8b3e675d72..3fb28bce26f0e0961a530f3025619d6c77eeed46
@@@ -376,10 -358,8 +376,10 @@@ thread_master_create (void
    rv->background = pqueue_create();
    rv->timer->cmp = rv->background->cmp = thread_timer_cmp;
    rv->timer->update = rv->background->update = thread_timer_update;
 +  rv->spin = true;
 +  rv->handle_signals = true;
  
- #if defined(HAVE_POLL)
+ #if defined(HAVE_POLL_CALL)
    rv->handler.pfdsize = rv->fd_limit;
    rv->handler.pfdcount = 0;
    rv->handler.pfds = XCALLOC (MTYPE_THREAD_MASTER,
@@@ -541,9 -516,8 +541,9 @@@ thread_master_free (struct thread_maste
    thread_list_free (m, &m->ready);
    thread_list_free (m, &m->unuse);
    thread_queue_free (m, m->background);
 +  pthread_mutex_destroy (&m->mtx);
  
- #if defined(HAVE_POLL)
+ #if defined(HAVE_POLL_CALL)
    XFREE (MTYPE_THREAD_MASTER, m->handler.pfds);
  #endif
    XFREE (MTYPE_THREAD_MASTER, m);
@@@ -698,29 -650,12 +698,29 @@@ static in
  fd_select (struct thread_master *m, int size, thread_fd_set *read, thread_fd_set *write, thread_fd_set *except, struct timeval *timer_wait)
  {
    int num;
- #if defined(HAVE_POLL)
 +
 +  /* If timer_wait is null here, that means either select() or poll() should
 +   * block indefinitely, unless the thread_master has overriden it. select()
 +   * and poll() differ in the timeout values they interpret as an indefinite
 +   * block; select() requires a null pointer, while poll takes a millisecond
 +   * value of -1.
 +   *
 +   * The thread_master owner has the option of overriding the default behavior
 +   * by setting ->selectpoll_timeout. If the value is positive, it specifies
 +   * the maximum number of milliseconds to wait. If the timeout is -1, it
 +   * specifies that we should never wait and always return immediately even if
 +   * no event is detected. If the value is zero, the behavior is default.
 +   */
 +
 -  /* recalc timeout for poll. Attention NULL pointer is no timeout with
 -  select, where with poll no timeount is -1 */
+ #if defined(HAVE_POLL_CALL)
    int timeout = -1;
 -  if (timer_wait != NULL)
 +
 +  if (timer_wait != NULL && m->selectpoll_timeout == 0) // use the default value
      timeout = (timer_wait->tv_sec*1000) + (timer_wait->tv_usec/1000);
 +  else if (m->selectpoll_timeout > 0) // use the user's timeout
 +    timeout = m->selectpoll_timeout;
 +  else if (m->selectpoll_timeout < 0) // effect a poll (return immediately)
 +    timeout = 0;
  
    num = poll (m->handler.pfds, m->handler.pfdcount + m->handler.pfdcountsnmp, timeout);
  #else
@@@ -781,49 -703,36 +781,49 @@@ funcname_thread_add_read_write (int dir
  {
    struct thread *thread = NULL;
  
 -#if !defined(HAVE_POLL_CALL)
 -  thread_fd_set *fdset = NULL;
 -  if (dir == THREAD_READ)
 -    fdset = &m->handler.readfd;
 -  else
 -    fdset = &m->handler.writefd;
 -#endif
 -
 +  pthread_mutex_lock (&m->mtx);
 +  {
- #if defined (HAVE_POLL)
+ #if defined (HAVE_POLL_CALL)
 -  thread = generic_thread_add(m, func, arg, fd, dir, debugargpass);
 -
 -  if (thread == NULL)
 -    return NULL;
 +    thread = generic_thread_add(m, func, arg, fd, dir, debugargpass);
  #else
 -  if (FD_ISSET (fd, fdset))
 -    {
 -      zlog_warn ("There is already %s fd [%d]",
 -                 (dir == THREAD_READ) ? "read" : "write", fd);
 -      return NULL;
 -    }
 +    if (fd >= FD_SETSIZE)
 +      {
 +        zlog_err ("File descriptor %d is >= FD_SETSIZE (%d). Please recompile"
 +                  "with --enable-poll=yes", fd, FD_SETSIZE);
 +        assert (fd < FD_SETSIZE && !"fd >= FD_SETSIZE");
 +      }
 +    thread_fd_set *fdset = NULL;
 +    if (dir == THREAD_READ)
 +      fdset = &m->handler.readfd;
 +    else
 +      fdset = &m->handler.writefd;
  
 -  FD_SET (fd, fdset);
 -  thread = thread_get (m, dir, func, arg, debugargpass);
 +    if (FD_ISSET (fd, fdset))
 +      {
 +        zlog_warn ("There is already %s fd [%d]",
 +                   (dir == THREAD_READ) ? "read" : "write", fd);
 +      }
 +    else
 +      {
 +        FD_SET (fd, fdset);
 +        thread = thread_get (m, dir, func, arg, debugargpass);
 +      }
  #endif
  
 -  thread->u.fd = fd;
 -  if (dir == THREAD_READ)
 -    thread_add_fd (m->read, thread);
 -  else
 -    thread_add_fd (m->write, thread);
 +    if (thread)
 +      {
 +        pthread_mutex_lock (&thread->mtx);
 +        {
 +          thread->u.fd = fd;
 +          if (dir == THREAD_READ)
 +            thread_add_fd (m->read, thread);
 +          else
 +            thread_add_fd (m->write, thread);
 +        }
 +        pthread_mutex_unlock (&thread->mtx);
 +      }
 +  }
 +  pthread_mutex_unlock (&m->mtx);
  
    return thread;
  }
diff --cc lib/thread.h
Simple merge
Simple merge
diff --cc pimd/pim_cmd.c
Simple merge
Simple merge
diff --cc pimd/pim_rp.c
Simple merge
diff --cc pimd/pim_vty.c
Simple merge
Simple merge
Simple merge