Exemplo n.º 1
0
int proxy_netio_set(int strm_type, pr_netio_t *netio) {
  /* Note: we DO want to unregister the registered stream type, assuming we
   * have a NetIO of our own to use for that type.
   */
  switch (strm_type) {
    case PR_NETIO_STRM_CTRL:
      if (ctrl_netio != NULL) {
        (void) pr_unregister_netio(strm_type);
      }
      break;

    case PR_NETIO_STRM_DATA:
      if (data_netio != NULL) {
        (void) pr_unregister_netio(strm_type);
      }
      break;

    default:
      break;
  }

  if (netio != NULL) {
    if (pr_register_netio(netio, strm_type) < 0) {
      pr_trace_msg(trace_channel, 3,
        "error registering previous %s NetIO: %s",
        netio_strm_typestr(strm_type), strerror(errno));
    }
  }

  return 0;
}
Exemplo n.º 2
0
static void tear_down(void) {
  pr_response_register_handler(NULL);

  if (session.c != NULL) {
    pr_inet_close(p, session.c);
    session.c = NULL;
  }

  pr_unregister_netio(PR_NETIO_STRM_CTRL);

  if (getenv("TEST_VERBOSE") != NULL) {
    pr_trace_set_levels("netio", 0, 0);
    pr_trace_set_levels("response", 0, 0);
  }

  (void) unlink(display_test_file);

  if (p) {
    destroy_pool(p);
    p = session.pool = permanent_pool = NULL;
  }
}
Exemplo n.º 3
0
pr_netio_t *proxy_netio_unset(int strm_type, const char *fn) {
  pr_netio_t *netio = NULL;

  if (fn == NULL) {
    errno = EINVAL;
    return NULL;
  }

  netio = pr_get_netio(strm_type);
  if (netio != NULL) {
    const char *owner_name = "core", *typestr;

    if (netio->owner_name != NULL) {
      owner_name = netio->owner_name;
    }
    typestr = netio_strm_typestr(strm_type);

    pr_trace_msg(trace_channel, 18, "(%s) found %s %s NetIO", fn, owner_name,
      typestr);
    if (pr_unregister_netio(strm_type) < 0) {
      pr_trace_msg(trace_channel, 3,
        "(%s) error unregistering %s NetIO: %s", fn, typestr, strerror(errno));
    }
  }

  /* Regardless of whether we found a previously registered NetIO, make
   * sure to use our own NetIO, if any.
   */
  switch (strm_type) {
    case PR_NETIO_STRM_CTRL:
      if (ctrl_netio != NULL) {
        if (pr_register_netio(ctrl_netio, strm_type) < 0) {
          pr_trace_msg(trace_channel, 3,
            "(%s) error registering proxy %s NetIO: %s", fn,
            netio_strm_typestr(strm_type), strerror(errno));

        } else {
          pr_trace_msg(trace_channel, 19,
            "(%s) using proxy %s NetIO", fn, netio_strm_typestr(strm_type));
        }
      }
      break;

    case PR_NETIO_STRM_DATA:
      if (data_netio != NULL) {
        if (pr_register_netio(data_netio, strm_type) < 0) {
          pr_trace_msg(trace_channel, 3,
            "(%s) error registering proxy %s NetIO: %s", fn,
            netio_strm_typestr(strm_type), strerror(errno));

        } else {
          pr_trace_msg(trace_channel, 19,
            "(%s) using proxy %s NetIO", fn, netio_strm_typestr(strm_type));
        }
      }
      break;

    default:
      break;
  }
 
  return netio;
}