support passing args to request handle for elimination of global var
This commit is contained in:
parent
79124c6e5c
commit
486b38d679
8 changed files with 120 additions and 19 deletions
|
|
@ -76,7 +76,8 @@ void xcecli_ctx_fini(xcecli_ctx_t c)
|
|||
free(ctx);
|
||||
}
|
||||
|
||||
int xcecli_set_handler(xcecli_ctx_t c, xce_request_handler_t handler)
|
||||
int xcecli_set_handler(xcecli_ctx_t c, xce_request_handler_t handler,
|
||||
void* args)
|
||||
{
|
||||
api_ctx_t* ctx = (api_ctx_t*)c;
|
||||
|
||||
|
|
@ -84,7 +85,7 @@ int xcecli_set_handler(xcecli_ctx_t c, xce_request_handler_t handler)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
return xce_ctx_set_handler(&(ctx->ctx), handler);
|
||||
return xce_ctx_set_handler(&(ctx->ctx), handler, args);
|
||||
}
|
||||
|
||||
int xcecli_wakeup(xcecli_ctx_t c, int status)
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ static int vtask_entry(vtask_t* task)
|
|||
}
|
||||
|
||||
if (callnext) {
|
||||
rc = (ctx->handler)(&request);
|
||||
rc = (ctx->handler)(&request, ctx->handler_args);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -198,13 +198,16 @@ void xce_ctx_fini(xce_ctx_t* ctx)
|
|||
return;
|
||||
}
|
||||
|
||||
int xce_ctx_set_handler(xce_ctx_t* ctx, xce_request_handler_t handler)
|
||||
int xce_ctx_set_handler(xce_ctx_t* ctx, xce_request_handler_t handler,
|
||||
void* args)
|
||||
{
|
||||
if ((ctx == NULL) || (handler == NULL)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ctx->handler = handler;
|
||||
ctx->handler = handler;
|
||||
ctx->handler_args = args;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue