|
On Apr 16, 2007, at 11:13 AM, Jesús Ruiz de Infante wrote:
Every process should get a copy of your global variables, not share them with other processes. Global variables are shared between (Posix) threads that are part of the same process, not between processes (the library loader usually uses copy-on-write pages to implement this). I would still prefer a reentrant solution though, so storing it in the module environment is the right thing to do. Your solution is a little complicated, you could just store the ident string passed as an argument itself, not a userdata object, why keep two copies of the same thing around when Lua string are immutable? When you need it you just use lua_tolstring to get the same string pointer again (and again). So your code simplified to: lua_pushvalue(L, 1);
If you're worried about efficiency you could store the string at integer index 1, but you'll bog down the syslog daemon long before that :-/ (syslogd tends to do an 'fsync' call after every write) Gé -- Gé Weijers |