static int mavis_init_in(mavis_ctx * mcx) { int i; DebugIn(DEBUG_MAVIS); mcx->lastdump = mcx->startup_time = time(NULL); if (!mcx->path) logmsg("Warning: %s: module lacks path definition", MAVIS_name); else if (!mcx->argv[0]) { mcx->argv[0] = Xstrdup(basename(mcx->path)); mcx->argv[1] = NULL; } if (mcx->child_min > mcx->child_max) mcx->child_min = mcx->child_max; if (!mcx->io_context_parent) mcx->io_context_local = mcx->io = io_init(); mcx->cx = Xcalloc(mcx->child_max, sizeof(struct context *)); mcx->cx_stat = Xcalloc(mcx->child_max, sizeof(struct context_stat)); for (i = 0; i < mcx->child_min; i++) fork_child(mcx, i); mcx->backlog_serial = RB_tree_new(compare_serial, NULL); mcx->backlog_app_ctx = RB_tree_new(compare_app_ctx, NULL); mcx->backlog_fifo = RB_tree_new(compare_fifo, free_payload); mcx->outgoing = RB_tree_new(compare_app_ctx, free_payload); mcx->junkcontexts = RB_tree_new(compare_ctx, free_context); DebugOut(DEBUG_MAVIS); return MAVIS_INIT_OK; }
void tac_script_set_exec_context(tac_session * session, char *username, char *portname, char *ctxname) { rb_node_t *rb = NULL; struct shellctx *sc; if (!session->ctx->single_connection_flag) { if (!session->ctx->single_connection_did_warn) { session->ctx->single_connection_did_warn = BISTATE_YES; report(session, LOG_INFO, ~0, "%s: Possibly no single-connection support. " "Context feature may or may not work.", session->ctx->nas_address_ascii); } } if (!session->ctx->shellctxcache && (!ctxname || !*ctxname)) return; if (session->ctx->shellctxcache) rb = tac_script_lookup_exec_context(session, username, portname); else session->ctx->shellctxcache = RB_tree_new(shellctx_cmp, shellctx_free); if (rb) { if (!ctxname || !*ctxname) { RB_delete(session->ctx->shellctxcache, rb); return; } sc = RB_payload(rb, struct shellctx *); free(sc->ctxname); } else {