Remove ctx evbase and dnsbase

We already have thr in conn ctx to access its evbase and dnsbase.
pull/48/head
Soner Tari 4 years ago
parent 8786b9fda7
commit d3c3059c26

@ -951,7 +951,7 @@ protossl_bufferevent_setup(pxy_conn_ctx_t *ctx, evutil_socket_t fd, SSL *ssl)
{
log_finest_va("ENTER, fd=%d", fd);
struct bufferevent *bev = bufferevent_openssl_socket_new(ctx->evbase, fd, ssl,
struct bufferevent *bev = bufferevent_openssl_socket_new(ctx->thr->evbase, fd, ssl,
((fd == -1) ? BUFFEREVENT_SSL_CONNECTING : BUFFEREVENT_SSL_ACCEPTING), BEV_OPT_DEFER_CALLBACKS);
if (!bev) {
log_err_level_printf(LOG_CRIT, "Error creating bufferevent socket\n");
@ -978,7 +978,7 @@ protossl_bufferevent_setup_child(pxy_conn_child_ctx_t *ctx, evutil_socket_t fd,
{
log_finest_va("ENTER, fd=%d", fd);
struct bufferevent *bev = bufferevent_openssl_socket_new(ctx->conn->evbase, fd, ssl,
struct bufferevent *bev = bufferevent_openssl_socket_new(ctx->conn->thr->evbase, fd, ssl,
((fd == -1) ? BUFFEREVENT_SSL_CONNECTING : BUFFEREVENT_SSL_ACCEPTING), BEV_OPT_DEFER_CALLBACKS);
if (!bev) {
log_err_level_printf(LOG_CRIT, "Error creating bufferevent socket\n");
@ -1181,7 +1181,7 @@ protossl_fd_readcb(evutil_socket_t fd, UNUSED short what, void *arg)
* reading now. We use 25 * 0.2 s = 5 s timeout. */
struct timeval retry_delay = {0, 100};
ctx->ev = event_new(ctx->evbase, fd, 0, protossl_fd_readcb, ctx);
ctx->ev = event_new(ctx->thr->evbase, fd, 0, protossl_fd_readcb, ctx);
if (!ctx->ev) {
log_err_level(LOG_CRIT, "Error creating retry event, aborting connection");
goto out;
@ -1202,7 +1202,7 @@ protossl_fd_readcb(evutil_socket_t fd, UNUSED short what, void *arg)
hints.ai_protocol = IPPROTO_TCP;
snprintf(sniport, sizeof(sniport), "%i", ctx->spec->sni_port);
evdns_getaddrinfo(ctx->dnsbase, ctx->sslctx->sni, sniport, &hints, protossl_sni_resolve_cb, ctx);
evdns_getaddrinfo(ctx->thr->dnsbase, ctx->sslctx->sni, sniport, &hints, protossl_sni_resolve_cb, ctx);
return;
}
@ -1232,7 +1232,7 @@ protossl_init_conn(evutil_socket_t fd, UNUSED short what, void *arg)
#endif /* !OPENSSL_NO_TLSEXT */
/* for SSL, defer dst connection setup to initial_readcb */
ctx->ev = event_new(ctx->evbase, ctx->fd, EV_READ, protossl_fd_readcb, ctx);
ctx->ev = event_new(ctx->thr->evbase, ctx->fd, EV_READ, protossl_fd_readcb, ctx);
if (!ctx->ev)
goto out;
@ -1281,7 +1281,7 @@ protossl_setup_srvdst(pxy_conn_ctx_t *ctx)
int
protossl_setup_srvdst_new_bev_ssl_connecting(pxy_conn_ctx_t *ctx)
{
ctx->srvdst.bev = bufferevent_openssl_filter_new(ctx->evbase, ctx->srvdst.bev, ctx->srvdst.ssl,
ctx->srvdst.bev = bufferevent_openssl_filter_new(ctx->thr->evbase, ctx->srvdst.bev, ctx->srvdst.ssl,
BUFFEREVENT_SSL_CONNECTING, BEV_OPT_DEFER_CALLBACKS);
if (!ctx->srvdst.bev) {
log_err_level_printf(LOG_CRIT, "Error creating srvdst bufferevent\n");
@ -1420,7 +1420,7 @@ protossl_setup_src(pxy_conn_ctx_t *ctx)
int
protossl_setup_src_new_bev_ssl_accepting(pxy_conn_ctx_t *ctx)
{
ctx->src.bev = bufferevent_openssl_filter_new(ctx->evbase, ctx->src.bev, ctx->src.ssl,
ctx->src.bev = bufferevent_openssl_filter_new(ctx->thr->evbase, ctx->src.bev, ctx->src.ssl,
BUFFEREVENT_SSL_ACCEPTING, BEV_OPT_DEFER_CALLBACKS);
if (!ctx->src.bev) {
log_err_level_printf(LOG_CRIT, "Error creating src bufferevent\n");
@ -1436,7 +1436,7 @@ protossl_setup_src_new_bev_ssl_accepting(pxy_conn_ctx_t *ctx)
int
protossl_setup_dst_new_bev_ssl_connecting_child(pxy_conn_child_ctx_t *ctx)
{
ctx->dst.bev = bufferevent_openssl_filter_new(ctx->conn->evbase, ctx->dst.bev, ctx->dst.ssl,
ctx->dst.bev = bufferevent_openssl_filter_new(ctx->conn->thr->evbase, ctx->dst.bev, ctx->dst.ssl,
BUFFEREVENT_SSL_CONNECTING, BEV_OPT_DEFER_CALLBACKS);
if (!ctx->dst.bev) {
log_err_level_printf(LOG_CRIT, "Error creating dst bufferevent\n");

@ -49,7 +49,7 @@ prototcp_bufferevent_setup(pxy_conn_ctx_t *ctx, evutil_socket_t fd)
{
log_finest_va("ENTER, fd=%d", fd);
struct bufferevent *bev = bufferevent_socket_new(ctx->evbase, fd, BEV_OPT_DEFER_CALLBACKS);
struct bufferevent *bev = bufferevent_socket_new(ctx->thr->evbase, fd, BEV_OPT_DEFER_CALLBACKS);
if (!bev) {
log_err_level(LOG_CRIT, "Error creating bufferevent socket");
return NULL;
@ -68,7 +68,7 @@ prototcp_bufferevent_setup_child(pxy_conn_child_ctx_t *ctx, evutil_socket_t fd)
{
log_finest_va("ENTER, fd=%d", fd);
struct bufferevent *bev = bufferevent_socket_new(ctx->conn->evbase, fd, BEV_OPT_DEFER_CALLBACKS);
struct bufferevent *bev = bufferevent_socket_new(ctx->conn->thr->evbase, fd, BEV_OPT_DEFER_CALLBACKS);
if (!bev) {
log_err_level(LOG_CRIT, "Error creating bufferevent socket");
return NULL;

@ -249,7 +249,7 @@ proxy_listener_acceptcb(UNUSED struct evconnlistener *listener,
// Switch from thrmgr to connection handling thread, i.e. change the event base, asap
// This prevents possible multithreading issues between thrmgr and conn handling threads
ctx->ev = event_new(ctx->evbase, -1, 0, ctx->protoctx->init_conn, ctx);
ctx->ev = event_new(ctx->thr->evbase, -1, 0, ctx->protoctx->init_conn, ctx);
if (!ctx->ev) {
log_err_level(LOG_CRIT, "Error creating initial event, aborting connection");
goto out;

@ -1520,7 +1520,7 @@ identify_user(UNUSED evutil_socket_t fd, UNUSED short what, void *arg)
// Do not forget to reset sqlite stmt, or else the userdb may remain busy/locked
sqlite3_reset(ctx->thr->get_user);
ctx->ev = event_new(ctx->evbase, -1, 0, identify_user, ctx);
ctx->ev = event_new(ctx->thr->evbase, -1, 0, identify_user, ctx);
if (!ctx->ev)
goto memout;
struct timeval retry_delay = {0, 100};

@ -246,9 +246,6 @@ struct pxy_conn_ctx {
proxyspec_t *spec;
global_t *global;
struct event_base *evbase;
struct evdns_base *dnsbase;
evutil_socket_t dst_fd;
evutil_socket_t srvdst_fd;

@ -234,8 +234,6 @@ pxy_thrmgr_attach(pxy_conn_ctx_t *ctx)
}
ctx->thr = tmctx->thr[thridx];
ctx->evbase = ctx->thr->evbase;
ctx->dnsbase = ctx->thr->dnsbase;
#ifdef DEBUG_THREAD
log_dbg_printf("thridx: %d\n", thridx);

Loading…
Cancel
Save