changeset 85:4303d94d87a2

rlgwebd.js: Unlink control socket at startup. Unlinking at shutdown doesn't work because at that time, the process is chroot'ed and unprivileged.
author John "Elwin" Edwards <elwin@sdf.org>
date Sun, 08 Jul 2012 17:49:43 -0700
parents d59dc5cef412
children ad4229cf8321
files rlgwebd.js
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/rlgwebd.js	Sun Jul 08 08:40:08 2012 -0700
+++ b/rlgwebd.js	Sun Jul 08 17:49:43 2012 -0700
@@ -992,7 +992,6 @@
   httpServer.close();
   httpServer.removeAllListeners('request');
   ctlServer.close();
-  fs.unlink(ctlsocket);
   tslog("Shutting down...");
   process.exit();
 }
@@ -1027,6 +1026,11 @@
 
 var httpServer; // declare here so shutdown() can find it
 
+/* This could be nonblocking, but nothing else can start yet anyway. */
+if (fs.existsSync(ctlsocket)) {
+  fs.unlinkSync(ctlsocket);
+}
+
 /* Open the control socket before chrooting where it can't be found */
 var ctlServer = net.createServer(function (sock) {
   sock.on('data', conHandler);