connectFree / lev

Levitate your app with Lev!
Apache License 2.0
101 stars 9 forks source link

assorted questions #97

Open dvv opened 12 years ago

dvv commented 12 years ago
  1. -c N switch spawns N workers, but do we respawn them on their death?
  2. IPC via /tmp is a known security hole -- it is not wise to communicate via something world-writeable (think of lev run under root)
kristate commented 12 years ago

@dvv, thank-you for your questions!

1) cores will not respawn on death -- they should not die. If a core dies something is wrong. 2) In the future, I would like multiple lev applications to be able to talk to each other. re: security, it might be important to invent some sort of handshaking mechanism or perhaps replace unix domain sockets with something better for IPC.

dvv commented 12 years ago

can we (do we have interface to) pass out-of-band file descriptors to write() calls?

kristate commented 12 years ago

@dvv yes, these are handled by _master[1] and _worker[2]. See net.lua[3] or examples/server-chat.lua[4] for an example on how to use the API.

The interface is exposed via the mbox object.

[1] https://github.com/connectFree/lev/blob/master/lib/lev/_master.lua [2] https://github.com/connectFree/lev/blob/master/lib/lev/_worker.lua [3] https://github.com/connectFree/lev/blob/master/lib/lev/net.lua [4] https://github.com/connectFree/lev/blob/master/examples/server-chat.lua

kristate commented 12 years ago

@dvv specifically, FDs can be sent on IPC pipes via the write method like so:

local fd = 9
ipc_pipe:write("this is data", fd)

FDs can be received on ipc-enabled pipes with this function signature:

ipc_client:read_start(function(c, nread, buf, fd, type)
   p("we have received an fd:", fd, "of type:", type)
end)
dvv commented 12 years ago

i'd like to be able to use lev as loadable module. for that, loop initialization etc. must be inside luaopen_levbase instead of pmain or alike. since lev_main.c starts with executing dostring(require('lev')) in both master and worker mode, this shouldn't be very difficult and is mostly question of moving some code. can it be done, or it is not feasible? tia

kristate commented 12 years ago

@dvv Lev is using a modified version of LuaJIT, so not all code may be compatible.