[prev in list] [next in list] [prev in thread] [next in thread] 

List:       spread-users
Subject:    [Spread-users] Cleanup of socket file
From:       Johannes Wienke <jwienke () techfak ! uni-bielefeld ! de>
Date:       2014-02-07 11:11:55
Message-ID: 52F4BF7B.4080805 () techfak ! uni-bielefeld ! de
[Download RAW message or body]

[Attachment #2 (multipart/signed)]

[Attachment #4 (multipart/mixed)]


Hi everyone,

we are working in a multiple user environment on Linux and constantly
had problems with left-over socket files in /tmp from spread. Once one
user has used spread and stopped the daemon another user on the same
machine is unable to start spread again on the same port because the
/tmp/4803 or whatever port file is still existing with permissions
preventing a deletion.

Attached is a prototypical patch against the current 4.4 beta release
that adds a signal handler to remove this file. I haven't tested this on
Windows and other esoteric platforms so it probably needs some fixes for
those. But it would be nice if this functionality could end up in the
final release.

Cheers,
Johannes

--=20
Johannes Wienke, Researcher at CoR-Lab / CITEC, Bielefeld University
Address: Inspiration 1, D-33619 Bielefeld, Germany (Room 1.307)
Phone: +49 521 106-67277

["0001-Clean-up-socket-file-on-signals.patch" (text/x-patch)]

From 0ac64baace62a8052595b1745a2df6ead3d467a6 Mon Sep 17 00:00:00 2001
From: Johannes Wienke <jwienke@techfak.uni-bielefeld.de>
Date: Fri, 7 Feb 2014 11:43:15 +0100
Subject: [PATCH] Clean up socket file on signals

---
 daemon/spread.c |   15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/daemon/spread.c b/daemon/spread.c
index c5586ec..299aa2b 100644
--- a/daemon/spread.c
+++ b/daemon/spread.c
@@ -53,6 +53,7 @@
 #  include <unistd.h>
 #  include <sys/types.h>
 #  include <sys/stat.h>
+#  include <signal.h>
 #endif
 
 #ifdef	ARCH_PC_WIN95
@@ -77,6 +78,17 @@ void ip_init(void);
 /* acp-permit.c: */
 void permit_init(void);
 
+void Cleanup_Socket(int sig)
+{
+    proc My = Conf_my();
+    char name[80];
+    snprintf( name, sizeof(name), "%s/%hu", SP_UNIX_SOCKET, My.port );
+    printf( "Cleaning up socket file %s\n", name );
+    unlink( name );
+    signal ( sig, SIG_DFL );
+    raise( sig );
+}
+
 #ifdef USE_SPREAD_MAIN
 int SpreadMain(int argc, char *argv[])
 #else
@@ -219,6 +231,9 @@ int main(int argc, char *argv[])
 
 #endif	/* ARCH_PC_WIN95 */
 
+    signal( SIGTERM, Cleanup_Socket );
+    signal( SIGINT, Cleanup_Socket );
+
 	E_handle_events();
 
 	return 0;
-- 
1.7.9.5


["signature.asc" (application/pgp-signature)]

_______________________________________________
Spread-users mailing list
Spread-users@lists.spread.org
http://lists.spread.org/mailman/listinfo/spread-users


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic