luv
luv copied to clipboard
Use socket from several fibers
I wrote simle tcp proxy. I have 2 fibers Fiber1 read from backend and write to frontend Fiber2 read from frontend and write to backend Fiber1 create Fiber2 and pass frontend sockt. All works. But on close all hungup. This i think relevant example. If need i can post all proxy.
local client = luv.net.tcp()
LOG.info("connect: ", client:connect(BACKEND.host, BACKEND.port))
local fib = luv.fiber.create(function()
LOG.trace("FIBER >>>", client:read())
end):ready()
LOG.trace("MAIN >>>", client:read())
fib:join()
LOG.info("close: ", client:close()) -- !!! this block forever
this output
2013-04-12 14:51:20 [INFO] connect: userdata<luv.net.tcp>: 0093E7F8 127.0.0.1
2013-04-12 14:51:22 [TRACE] MAIN >>> some data
2013-04-12 14:51:22 [TRACE] FIBER >>> other data
trace:
f:\e\installs\lua\luv\luv-master\src\luv_stream.c: 287: luvL_stream_close: close stream
f:\e\installs\lua\luv\luv-master\src\luv_object.c: 24: luvL_object_close: object closing 009483B0, type: 12
f:\e\installs\lua\luv\luv-master\src\luv_cond.c: 9: luvL_cond_wait: SUSPEND state 0090F348(thread)
f:\e\installs\lua\luv\luv-master\src\luv_object.c: 16: luvL_object_close_cb: object closed 009483B0
f:\e\installs\lua\luv\luv-master\src\luv_cond.c: 19: luvL_cond_signal: READY state 00948FB0