Libunit: added a function to discern main and worker contexts.

This commit is contained in:
Max Romanov
2020-10-28 00:01:46 +03:00
parent 28ab1de364
commit a5508cec7a
2 changed files with 13 additions and 0 deletions

View File

@@ -4854,6 +4854,17 @@ nxt_unit_run_shared(nxt_unit_ctx_t *ctx)
} }
int
nxt_unit_is_main_ctx(nxt_unit_ctx_t *ctx)
{
nxt_unit_impl_t *lib;
lib = nxt_container_of(ctx->unit, nxt_unit_impl_t, unit);
return (ctx == &lib->main_ctx.ctx);
}
int int
nxt_unit_process_port_msg(nxt_unit_ctx_t *ctx, nxt_unit_port_t *port) nxt_unit_process_port_msg(nxt_unit_ctx_t *ctx, nxt_unit_port_t *port)
{ {

View File

@@ -210,6 +210,8 @@ int nxt_unit_run_ctx(nxt_unit_ctx_t *ctx);
int nxt_unit_run_shared(nxt_unit_ctx_t *ctx); int nxt_unit_run_shared(nxt_unit_ctx_t *ctx);
int nxt_unit_is_main_ctx(nxt_unit_ctx_t *ctx);
/* /*
* Receive and process one message, invoke configured callbacks. * Receive and process one message, invoke configured callbacks.
* *