Ticket #3216: 0002-Don-t-try-to-build-descriptors-when-router_get_adver.patch

File 0002-Don-t-try-to-build-descriptors-when-router_get_adver.patch, 4.0 KB (added by nickm, 8 years ago)
  • src/or/connection.c

    From dcd950284d43310702d713851ec45bbb45c1d29c Mon Sep 17 00:00:00 2001
    From: Nick Mathewson <nickm@torproject.org>
    Date: Tue, 24 May 2011 11:55:08 -0400
    Subject: [PATCH 2/2] Don't try to build descriptors when
     router_get_advertised_or_port()==0
    
    The previous attempt was incomplete: it told us not to publish a
    descriptor, but didn't stop us from generating one.  Now we treat an
    absent OR port the same as not knowing our address.  (This means
    that when we _do_ get an OR port, we need to mark the descriptor
    dirty.)
    
    More attempt to fix bug3216.
    ---
     src/or/connection.c |   26 +++++++++++++++++++-------
     src/or/router.c     |    3 ++-
     2 files changed, 21 insertions(+), 8 deletions(-)
    
    diff --git a/src/or/connection.c b/src/or/connection.c
    index bcdde67..ad3dfde 100644
    a b retry_all_listeners(smartlist_t *replaced_conns, 
    19501950                    smartlist_t *new_conns)
    19511951{
    19521952  or_options_t *options = get_options();
     1953  int retval = 0;
     1954  const uint16_t old_or_port = router_get_advertised_or_port(options);
     1955  const uint16_t old_dir_port = router_get_advertised_dir_port(options);
    19531956
    19541957  if (retry_listeners(CONN_TYPE_OR_LISTENER, options->ORListenAddress,
    19551958                      options->ORPort, "0.0.0.0",
    19561959                      replaced_conns, new_conns, options->ClientOnly,
    19571960                      AF_INET)<0)
    1958     return -1;
     1961    retval = -1;
    19591962  if (retry_listeners(CONN_TYPE_DIR_LISTENER, options->DirListenAddress,
    19601963                      options->DirPort, "0.0.0.0",
    19611964                      replaced_conns, new_conns, options->ClientOnly,
    19621965                      AF_INET)<0)
    1963     return -1;
     1966    retval = -1;
    19641967  if (retry_listeners(CONN_TYPE_AP_LISTENER, options->SocksListenAddress,
    19651968                      options->SocksPort, "127.0.0.1",
    19661969                      replaced_conns, new_conns, 0,
    19671970                      AF_INET)<0)
    1968     return -1;
     1971    retval = -1;
    19691972  if (retry_listeners(CONN_TYPE_AP_TRANS_LISTENER, options->TransListenAddress,
    19701973                      options->TransPort, "127.0.0.1",
    19711974                      replaced_conns, new_conns, 0,
    19721975                      AF_INET)<0)
    1973     return -1;
     1976    retval = -1;
    19741977  if (retry_listeners(CONN_TYPE_AP_NATD_LISTENER, options->NATDListenAddress,
    19751978                      options->NATDPort, "127.0.0.1",
    19761979                      replaced_conns, new_conns, 0,
    19771980                      AF_INET)<0)
    1978     return -1;
     1981    retval = -1;
    19791982  if (retry_listeners(CONN_TYPE_AP_DNS_LISTENER, options->DNSListenAddress,
    19801983                      options->DNSPort, "127.0.0.1",
    19811984                      replaced_conns, new_conns, 0,
    19821985                      AF_INET)<0)
    1983     return -1;
     1986    retval = -1;
    19841987  if (retry_listeners(CONN_TYPE_CONTROL_LISTENER,
    19851988                      options->ControlListenAddress,
    19861989                      options->ControlPort, "127.0.0.1",
    retry_all_listeners(smartlist_t *replaced_conns, 
    19941997                      AF_UNIX)<0)
    19951998    return -1;
    19961999
    1997   return 0;
     2000  if (old_or_port != router_get_advertised_or_port(options) ||
     2001      old_dir_port != router_get_advertised_dir_port(options)) {
     2002    /* Our chosen ORPort or DirPort is not what it used to be: the
     2003     * descriptor we had (if any) should be regenerated.  (We won't
     2004     * automatically notice this because of changes in the option,
     2005     * since the value could be "auto".) */
     2006    mark_my_descriptor_dirty();
     2007  }
     2008
     2009  return retval;
    19982010}
    19992011
    20002012/** Return 1 if we should apply rate limiting to <b>conn</b>,
  • src/or/router.c

    diff --git a/src/or/router.c b/src/or/router.c
    index 6a4664b..5701eca 100644
    a b router_rebuild_descriptor(int force) 
    14191419  if (desc_clean_since && !force)
    14201420    return 0;
    14211421
    1422   if (router_pick_published_address(options, &addr) < 0) {
     1422  if (router_pick_published_address(options, &addr) < 0 ||
     1423      router_get_advertised_or_port() == 0)
    14231424    /* Stop trying to rebuild our descriptor every second. We'll
    14241425     * learn that it's time to try again when ip_address_changed()
    14251426     * marks it dirty. */