Back to index

tor  0.2.3.18-rc
Defines | Functions
transports.h File Reference

Headers for transports.c. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define pt_kickstart_client_proxy(tl, pa)   pt_kickstart_proxy(tl, pa, 0)
#define pt_kickstart_server_proxy(tl, pa)   pt_kickstart_proxy(tl, pa, 1)

Functions

void pt_kickstart_proxy (const smartlist_t *transport_list, char **proxy_argv, int is_server)
 Register proxy with proxy_argv, supporting transports in transport_list, to the managed proxy subsystem.
void pt_configure_remaining_proxies (void)
 Check if any of the managed proxies we are currently trying to configure have anything new to say.
int pt_proxies_configuration_pending (void)
 Return true if there are still unconfigured managed proxies, or proxies that need restarting.
void pt_free_all (void)
 Release all storage held by the pluggable transports subsystem.
void pt_prepare_proxy_list_for_config_read (void)
 Tor will read its config.
void sweep_proxy_list (void)
 The tor config was read.

Detailed Description

Headers for transports.c.

Definition in file transports.h.


Define Documentation

#define pt_kickstart_client_proxy (   tl,
  pa 
)    pt_kickstart_proxy(tl, pa, 0)

Definition at line 17 of file transports.h.

#define pt_kickstart_server_proxy (   tl,
  pa 
)    pt_kickstart_proxy(tl, pa, 1)

Definition at line 19 of file transports.h.


Function Documentation

Check if any of the managed proxies we are currently trying to configure have anything new to say.

This is called from run_scheduled_events().

Definition at line 316 of file transports.c.

{
  smartlist_t *tmp = smartlist_new();

  log_debug(LD_CONFIG, "Configuring remaining managed proxies (%d)!",
            unconfigured_proxies_n);

  /* Iterate over tmp, not managed_proxy_list, since configure_proxy can
   * remove elements from managed_proxy_list. */
  smartlist_add_all(tmp, managed_proxy_list);

  assert_unconfigured_count_ok();

  SMARTLIST_FOREACH_BEGIN(tmp,  managed_proxy_t *, mp) {
    tor_assert(mp->conf_state != PT_PROTO_BROKEN ||
               mp->conf_state != PT_PROTO_FAILED_LAUNCH);

    if (mp->got_hup) {
      mp->got_hup = 0;

      /* This proxy is marked by a SIGHUP. Check whether we need to
         restart it. */
      if (proxy_needs_restart(mp)) {
        log_info(LD_GENERAL, "Preparing managed proxy '%s' for restart.",
                 mp->argv[0]);
        proxy_prepare_for_restart(mp);
      } else { /* it doesn't need to be restarted. */
        log_info(LD_GENERAL, "Nothing changed for managed proxy '%s' after "
                 "HUP: not restarting.", mp->argv[0]);
      }

      continue;
    }

    /* If the proxy is not fully configured, try to configure it
       futher. */
    if (!proxy_configuration_finished(mp))
      configure_proxy(mp);

  } SMARTLIST_FOREACH_END(mp);

  smartlist_free(tmp);
  check_if_restarts_needed = 0;
  assert_unconfigured_count_ok();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pt_free_all ( void  )

Release all storage held by the pluggable transports subsystem.

Definition at line 1205 of file transports.c.

{
  if (managed_proxy_list) {
    /* If the proxy is in PT_PROTO_COMPLETED, it has registered its
       transports and it's the duty of the circuitbuild.c subsystem to
       free them. Otherwise, it hasn't registered its transports yet
       and we should free them here. */
    SMARTLIST_FOREACH(managed_proxy_list, managed_proxy_t *, mp, {
        SMARTLIST_DEL_CURRENT(managed_proxy_list, mp);
        managed_proxy_destroy(mp, 1);
    });

    smartlist_free(managed_proxy_list);
    managed_proxy_list=NULL;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pt_kickstart_proxy ( const smartlist_t transport_list,
char **  proxy_argv,
int  is_server 
)

Register proxy with proxy_argv, supporting transports in transport_list, to the managed proxy subsystem.

If is_server is true, then the proxy is a server proxy.

Takes ownership of proxy_argv.

Requires that proxy_argv be a NULL-terminated array of command-line elements, containing at least one element.

Definition at line 1096 of file transports.c.

{
  managed_proxy_t *mp=NULL;
  transport_t *old_transport = NULL;

  if (!proxy_argv || !proxy_argv[0]) {
    return;
  }

  mp = get_managed_proxy_by_argv_and_type(proxy_argv, is_server);

  if (!mp) { /* we haven't seen this proxy before */
    managed_proxy_create(transport_list, proxy_argv, is_server);

  } else { /* known proxy. add its transport to its transport list */
    if (mp->got_hup) {
      /* If the managed proxy we found is marked by a SIGHUP, it means
         that it's not useless and should be kept. If it's marked for
         removal, unmark it and increase the unconfigured proxies so
         that we try to restart it if we need to. Afterwards, check if
         a transport_t for 'transport' used to exist before the SIGHUP
         and make sure it doesn't get deleted because we might reuse
         it. */
      if (mp->marked_for_removal) {
        mp->marked_for_removal = 0;
        check_if_restarts_needed = 1;
      }

      SMARTLIST_FOREACH_BEGIN(transport_list, const char *, transport) {
        old_transport = transport_get_by_name(transport);
        if (old_transport)
          old_transport->marked_for_removal = 0;
      } SMARTLIST_FOREACH_END(transport);
    }

    SMARTLIST_FOREACH(transport_list, const char *, transport,
                      add_transport_to_proxy(transport, mp));
    free_execve_args(proxy_argv);
  }
}

Here is the call graph for this function:

Tor will read its config.

Prepare the managed proxy list so that proxies not used in the new config will shutdown, and proxies that need to spawn different transports will do so.

Definition at line 1156 of file transports.c.

{
  if (!managed_proxy_list)
    return;

  assert_unconfigured_count_ok();
  SMARTLIST_FOREACH_BEGIN(managed_proxy_list, managed_proxy_t *, mp) {
    /* Destroy unconfigured proxies. */
    if (mp->conf_state != PT_PROTO_COMPLETED) {
      SMARTLIST_DEL_CURRENT(managed_proxy_list, mp);
      managed_proxy_destroy(mp, 1);
      unconfigured_proxies_n--;
      continue;
    }

    tor_assert(mp->conf_state == PT_PROTO_COMPLETED);

    mp->marked_for_removal = 1;
    mp->got_hup = 1;
    SMARTLIST_FOREACH(mp->transports_to_launch, char *, t, tor_free(t));
    smartlist_clear(mp->transports_to_launch);
  } SMARTLIST_FOREACH_END(mp);

  assert_unconfigured_count_ok();

  tor_assert(unconfigured_proxies_n == 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Return true if there are still unconfigured managed proxies, or proxies that need restarting.

Definition at line 140 of file transports.c.

Here is the caller graph for this function:

void sweep_proxy_list ( void  )

The tor config was read.

Destroy all managed proxies that were marked by a previous call to prepare_proxy_list_for_config_read() and are not used by the new config.

Definition at line 1189 of file transports.c.

Here is the call graph for this function:

Here is the caller graph for this function: