-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hi, can nixio socket object been passed to another thread? #7
Comments
Simple answer: There is no support for this. Longer answer: If you still want to try using sendfile from a thread then you could create a very simple C module that only wraps the sendfile() function. That function would take the in/out FD as numbers instead of objects. This would be a quick way to test if this design will work for you. There may also be some issues with lua-handlers when trying to write to the socket from another thread. Write timeout, flushing the internal connection write buffer. I think the best way to scale would be to use nodejs's cluster design where the server forks multiple child worker processes that have shared access to the listening sockets. I am working on a new design for lua-handlers that supports different backends for IO/events: I am trying to replace nixio with a new module lua-llnet: lua-llnet has much better performance under LuaJIT since it uses the FFI interface. I am planning on adding support for sending an FD over a Unix Domain socket (this is needed to support nodejs's clustering design), this feature could be used for passing a socket to another thread. There are still a few missing features (timers/signal fd support with the epoll backend, and TLS sockets) before I release the new lua-handlers design. |
ok, thank you, I'll follow your progress. :) |
can wrap this nixio socket object to a light userdata, and pass to another thread, like your lua-zmq-threads? |
no. The zeromq context is designed to be shared between threads. The nixio socket objects are just wrappers for the socket FD. You will run into problems with the GC like I outlined in my previous comment. |
hi neo,
I am using lua-handlers to write a http server. Now I want to process static files in other threads, so after parse the http request, I need to pass the file uri and nixio socket object to other threads (I use lua-llthreads), other threads use nixion.sendfile to server files, so they must get the socket object to response correctly. How should I do to pass socket object?
Expect your reply.
Thank you.
The text was updated successfully, but these errors were encountered: