forked from openresty/lua-nginx-module
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathngx_http_lua_worker.c
More file actions
48 lines (32 loc) · 840 Bytes
/
Copy pathngx_http_lua_worker.c
File metadata and controls
48 lines (32 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
* Copyright (C) Yichun Zhang (agentzh)
*/
#ifndef DDEBUG
#define DDEBUG 0
#endif
#include "ddebug.h"
#include "ngx_http_lua_worker.h"
static int ngx_http_lua_ngx_worker_exiting(lua_State *L);
static int ngx_http_lua_ngx_worker_pid(lua_State *L);
void
ngx_http_lua_inject_worker_api(lua_State *L)
{
lua_createtable(L, 0 /* narr */, 1 /* nrec */); /* ngx.timer. */
lua_pushcfunction(L, ngx_http_lua_ngx_worker_exiting);
lua_setfield(L, -2, "exiting");
lua_pushcfunction(L, ngx_http_lua_ngx_worker_pid);
lua_setfield(L, -2, "pid");
lua_setfield(L, -2, "worker");
}
static int
ngx_http_lua_ngx_worker_exiting(lua_State *L)
{
lua_pushboolean(L, ngx_exiting);
return 1;
}
static int
ngx_http_lua_ngx_worker_pid(lua_State *L)
{
lua_pushinteger(L, (lua_Integer) ngx_pid);
return 1;
}