Dammit, I just realized there was a bug in my implementation, here is a patch to fix it.
PS: I know Julien would want me to do something fancy with Git to create a new merged patch. However I am clueless in git, if someone tells me how to merge two commits into one I would be happy to resubmit the patch. Cheers, Alex On Thu, Mar 19, 2009 at 7:55 PM, Alex Cornejo <[email protected]> wrote: > Here are a couple of patches to implement the described fallback logic. > > Right now we query HOME, TMPDIR and /tmp, in that order. However its > trivial to add more fallbacks (either from environment variables or fixed > strings). > > Cheers, > > Alex > > > On Thu, Mar 19, 2009 at 1:09 PM, Julien Danjou <[email protected]> wrote: > >> At 1237473819 time_t, Alex Cornejo wrote: >> > That function would then take care of all the fallback logic and print >> out >> > any warning/error messages. What do you think? >> >> Seems ok to me. >> >> Cheers, >> -- >> Julien Danjou >> // ᐰ <[email protected]> http://julien.danjou.info >> // 9A0D 5FD9 EB42 22F6 8974 C95C A462 B51E C2FE E5CD >> // When I get sad, I stop being sad and be awesome instead. True story. >> >> -----BEGIN PGP SIGNATURE----- >> Version: GnuPG v1.4.9 (GNU/Linux) >> >> iEYEARECAAYFAknCfEEACgkQpGK1HsL+5c2XvQCdFT5rsskvLs35NIDX/ebPiofr >> WpwAoKvoLKxh2dGoUeATdo3QKBD00njT >> =BwEH >> -----END PGP SIGNATURE----- >> >> >
From 40377d7e20ed057680e002079fb072f13d107e94 Mon Sep 17 00:00:00 2001 From: Alex Cornejo <[email protected]> Date: Thu, 19 Mar 2009 19:56:19 -0400 Subject: [PATCH] Fixed bug in socket_open. Corrected behaviour when bind succeeds after unlinking. Signed-off-by: Alex Cornejo <[email protected]> --- common/socket.c | 9 +++------ luaa.c | 3 +++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/common/socket.c b/common/socket.c index f21eebb..3298f45 100644 --- a/common/socket.c +++ b/common/socket.c @@ -83,13 +83,10 @@ struct sockaddr_un *socket_open(int csfd, const char *display, const socket_mode { if(unlink(addr->sun_path)) warn("error unlinking existing file: %s", strerror(errno)); - if(bind(csfd, (const struct sockaddr *) addr, SUN_LEN(addr))) - { - warn("error binding UNIX domain socket: %s", strerror(errno)); - break; - } + if(!bind(csfd, (const struct sockaddr *) addr, SUN_LEN(addr))) + status = 0; + else break; } - else continue; } else if(!connect(csfd, (const struct sockaddr *)addr, sizeof(struct sockaddr_un))) status = 0; diff --git a/luaa.c b/luaa.c index 421041c..aae7640 100644 --- a/luaa.c +++ b/luaa.c @@ -1121,7 +1121,10 @@ luaA_cs_init(void) #endif if(!(addr = socket_open(csfd, getenv("DISPLAY"), Bind))) + { + warn("error binding UNIX domain socket: %s", strerror(errno)); return; + } listen(csfd, 10); ev_io_init(&csio, &luaA_conn_cb, csfd, EV_READ); -- 1.5.6.3
