File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change 7474
7575if is_not_windows then
7676 if subsystem == " http" then
77+ require " resty.core.phase" -- for ngx.get_phase
78+
7779 ffi .cdef [[
7880 int ngx_http_lua_ffi_worker_pids (int * pids , size_t * pids_len );
7981 ]]
@@ -88,16 +90,18 @@ if is_not_windows then
8890 ngx_lua_ffi_worker_pids = C .ngx_stream_lua_ffi_worker_pids
8991 end
9092
93+ local ngx_phase = ngx .get_phase
9194
9295 function ngx .worker .pids ()
93- if ngx .get_phase () == " init" or ngx .get_phase () == " init_worker" then
96+ local phase = ngx_phase ()
97+ if phase == " init" or phase == " init_worker" then
9498 return nil , " API disabled in the current context"
9599 end
96100
97101 local pids = {}
98102 local size_ptr = get_size_ptr ()
99103 -- the old and the new workers coexist during reloading
100- local worker_cnt = ngx . worker . count () * 4
104+ local worker_cnt = ngx_lua_ffi_worker_count () * 4
101105 if worker_cnt == 0 then
102106 return pids
103107 end
@@ -117,6 +121,7 @@ if is_not_windows then
117121 end
118122end
119123
124+
120125function ngx .worker .id ()
121126 local id = ngx_lua_ffi_worker_id ()
122127 if id < 0 then
You can’t perform that action at this time.
0 commit comments