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; }
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; }
void init_netio(void) { signal(SIGPIPE, SIG_IGN); signal(SIGURG, SIG_IGN); pr_register_netio(NULL, 0); }