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
64 lines (44 loc) · 1023 Bytes
/
Copy pathngx_http_lua_worker.c
File metadata and controls
64 lines (44 loc) · 1023 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
* 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 */, 2 /* nrec */); /* ngx.worker. */
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;
}
#ifndef NGX_LUA_NO_FFI_API
int
ngx_http_lua_ffi_worker_pid(void)
{
return (int) ngx_pid;
}
int
ngx_http_lua_ffi_worker_exiting(void)
{
return (int) ngx_exiting;
}
#endif