Skip to content

Commit 004922e

Browse files
feature: Export three functions for manipulating ngx_http_lua_co_ctx_t structures.
1 parent 5bd471a commit 004922e

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

src/api/ngx_http_lua_api.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121

2222
#define ngx_http_lua_version 10028
23+
#define NGX_HTTP_LUA_EXPORT_CO_CTX_CLEANUP 1
2324

2425

2526
typedef struct ngx_http_lua_co_ctx_s ngx_http_lua_co_ctx_t;
@@ -66,6 +67,13 @@ void ngx_http_lua_set_cur_co_ctx(ngx_http_request_t *r,
6667

6768
lua_State *ngx_http_lua_get_co_ctx_vm(ngx_http_lua_co_ctx_t *coctx);
6869

70+
71+
void *ngx_http_lua_get_co_ctx_data(ngx_http_lua_co_ctx_t *coctx);
72+
void ngx_http_lua_set_co_ctx_cleanup(ngx_http_lua_co_ctx_t *coctx,
73+
ngx_http_cleanup_pt cleanup, void *data);
74+
void ngx_http_lua_cleanup_co_ctx_pending_operation(
75+
ngx_http_lua_co_ctx_t *coctx);
76+
6977
void ngx_http_lua_co_ctx_resume_helper(ngx_http_lua_co_ctx_t *coctx, int nrets);
7078

7179
int ngx_http_lua_get_lua_http10_buffering(ngx_http_request_t *r);

src/ngx_http_lua_api.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ ngx_http_lua_get_cur_co_ctx(ngx_http_request_t *r)
221221

222222
ctx = ngx_http_get_module_ctx(r, ngx_http_lua_module);
223223

224-
return ctx->cur_co_ctx;
224+
return ctx == NULL ? NULL : ctx->cur_co_ctx;
225225
}
226226

227227

@@ -245,6 +245,29 @@ ngx_http_lua_get_co_ctx_vm(ngx_http_lua_co_ctx_t *coctx)
245245
}
246246

247247

248+
void *
249+
ngx_http_lua_get_co_ctx_data(ngx_http_lua_co_ctx_t *coctx)
250+
{
251+
return coctx ? coctx->data : NULL;
252+
}
253+
254+
255+
void
256+
ngx_http_lua_set_co_ctx_cleanup(ngx_http_lua_co_ctx_t *coctx,
257+
ngx_http_cleanup_pt cleanup, void *data)
258+
{
259+
coctx->cleanup = cleanup;
260+
coctx->data = data;
261+
}
262+
263+
264+
void
265+
ngx_http_lua_cleanup_co_ctx_pending_operation(ngx_http_lua_co_ctx_t *coctx)
266+
{
267+
ngx_http_lua_cleanup_pending_operation(coctx);
268+
}
269+
270+
248271
static ngx_int_t
249272
ngx_http_lua_co_ctx_resume(ngx_http_request_t *r)
250273
{

0 commit comments

Comments
 (0)