lcb_error_t lcbio_ssl_apply(lcbio_SOCKET *sock, lcbio_pSSLCTX sctx) { lcbio_pTABLE old_iot = sock->io, new_iot; lcbio_PROTOCTX *sproto; if (old_iot->model == LCB_IOMODEL_EVENT) { new_iot = lcbio_Essl_new(old_iot, sock->u.fd, sctx->ctx); } else { new_iot = lcbio_Cssl_new(old_iot, sock->u.sd, sctx->ctx); } if (new_iot) { sproto = calloc(1, sizeof(*sproto)); sproto->id = LCBIO_PROTOCTX_SSL; sproto->dtor = noop_dtor; lcbio_protoctx_add(sock, sproto); lcbio_table_unref(old_iot); sock->io = new_iot; /* just for logging */ SSL_set_app_data(((lcbio_XSSL *)new_iot)->ssl, sock); return LCB_SUCCESS; } else { return LCB_ERROR; } }
void iotssl_destroy_common(lcbio_XSSL *xs) { free(xs->iops_dummy_); SSL_free(xs->ssl); lcbio_table_unref(xs->orig); }
static void destroy_timer(lcb_timer_t timer) { if (timer->event) { timer->io->timer.destroy(timer->io->p, timer->event); } lcbio_table_unref(timer->io); memset(timer, 0xff, sizeof(*timer)); free(timer); }
void lcbio__destroy(lcbio_SOCKET *s) { lcbio_shutdown(s); if (s->info) { free(s->info); } lcbio_table_unref(s->io); lcb_settings_unref(s->settings); free(s); }