@@ -24,8 +24,6 @@ local setmetatable = setmetatable
2424local error = error
2525local ffi = require " ffi"
2626local ffi_new = ffi .new
27- local ffi_str = ffi .string
28- local C = ffi .C
2927local zmqlib = ffi .load (" zmq" )
3028local czmq = ffi .load (" czmq" )
3129
@@ -68,26 +66,10 @@ ffi.cdef[[
6866
6967local ctx_v = czmq .zctx_new ()
7068local 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
8669
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+
9173
9274function _M .new (self )
9375 return setmetatable ({}, mt )
0 commit comments