@@ -24,8 +24,6 @@ local setmetatable = setmetatable
24
24
local error = error
25
25
local ffi = require " ffi"
26
26
local ffi_new = ffi .new
27
- local ffi_str = ffi .string
28
- local C = ffi .C
29
27
local zmqlib = ffi .load (" zmq" )
30
28
local czmq = ffi .load (" czmq" )
31
29
@@ -68,26 +66,10 @@ ffi.cdef[[
68
66
69
67
local ctx_v = czmq .zctx_new ()
70
68
local ctx = ffi_new (" zctx_t *" , ctx_v )
71
- local socketInst
72
-
73
- local check_worker_delay = 5
74
- local function check_worker_process (premature )
75
- if not premature then
76
- local ok , err = ngx .timer .at (check_worker_delay , check_worker_process )
77
- if not ok then
78
- ngx .log (ngx .ERR , " failed to create timer to check worker process: " , err )
79
- end
80
- else
81
- ngx .log (ngx .INFO , " Terminating ZMQ context due to worker termination ..." )
82
- -- this should be called when the worker is stopped
83
- zmqlib .zmq_ctx_destroy (ctx )
84
- end
85
- end
86
69
87
- local ok , err = ngx .timer .at (check_worker_delay , check_worker_process )
88
- if not ok then
89
- ngx .log (ngx .ERR , " failed to create timer to check worker process: " , err )
90
- end
70
+ --- garbage collect with destroy
71
+ ffi .gc (ctx , zmqlib .zmq_ctx_destroy )
72
+
91
73
92
74
function _M .new (self )
93
75
return setmetatable ({}, mt )
0 commit comments