[systemd-devel] PATCH: tmpfiles cleanup

Michael Meeks michael.meeks at suse.com
Thu Jan 12 03:07:30 PST 2012


On Thu, 2012-01-12 at 10:10 +0000, Michael Meeks wrote:
> 	No problem; it is only the belt - not the braces; I'll knock up
> something more robust re-using the linc-cleanup-sockets goodness, that
> should also avoid the unpleasant race-condition in there whereby a
> socket is created between parsing /proc/net/unix and the deletion phase.

	Hah - my 'race' is more imaginary than real because of the atime,
mtime, ctime checks (we are actually using atime!?).

	Nevertheless, if we want to be truly clean socket-wise we could use
something like the attached ? this is also pretty quick to execute - so
unless there is some serious performance reason, we might consider
dropping the /proc/net/unix parsing altogether ? [ though of course my
understanding may be broken here, perhaps there are odd unix socket
types, and races, and so on that it will not handle ;-) ]

	HTH,

		Michael.


With the attached & layering this small debug patch on top, I get:

diff --git a/src/tmpfiles.c b/src/tmpfiles.c
index b3d17a7..e1c77c2 100644
--- a/src/tmpfiles.c
+++ b/src/tmpfiles.c
@@ -222,6 +222,8 @@ static bool unix_socket_alive(const char *fn) {
                 break;
         }
  done:
+        fprintf (stderr, "Socket '%s' - %s cnx %d errno %d\n",
+                 fn, ret ? "alive" : "dead", cnx, cnx < 0 ? errno : 0);
         if (sd >= 0)
                 close (sd);
 

	Layered on top, and the parsed cache disabled I get; run one:

Socket '/tmp/at-spi2/socket-9665-278722862' - dead cnx -1 errno 111
Socket '/tmp/at-spi2/socket-9683-1804289383' - dead cnx -1 errno 111
Socket '/tmp/at-spi2/socket-9658-782288962' - dead cnx -1 errno 111
Socket '/tmp/OSL_PIPE_1000_SingleOfficeIPC_2697e28e886d5a3223771cb079e42' - alive cnx 0 errno 0
Socket '/tmp/pulse-7VI5uG1yhc3u/dbus-socket' - alive cnx 0 errno 0
Socket '/tmp/pulse-7VI5uG1yhc3u/native' - alive cnx 0 errno 0
Socket '/tmp/orbit-michael/linc-1174-0-77e8714ad4876' - dead cnx -1 errno 111
Socket '/tmp/.esd-1000/socket' - alive cnx 0 errno 0
Socket '/tmp/OSL_PIPE_1000_SingleOfficeIPC_16adf7e8b0d32dc9df645db617f77752' - alive cnx 0 errno 0
Socket '/tmp/keyring-cNhiNs/pkcs11' - alive cnx 0 errno 0
Socket '/tmp/keyring-cNhiNs/control' - alive cnx 0 errno 0
Socket '/tmp/keyring-cNhiNs/ssh' - alive cnx 0 errno 0
Socket '/tmp/keyring-cNhiNs/gpg' - alive cnx 0 errno 0
Socket '/tmp/.X11-unix/X0' - alive cnx 0 errno 0
Socket '/tmp/.ICE-unix/9731' - alive cnx 0 errno 0

run two:

Socket '/tmp/OSL_PIPE_1000_SingleOfficeIPC_2697e28e886d5a3223771cb079e42' - alive cnx 0 errno 0
Socket '/tmp/pulse-7VI5uG1yhc3u/dbus-socket' - alive cnx 0 errno 0
Socket '/tmp/pulse-7VI5uG1yhc3u/native' - alive cnx 0 errno 0
Socket '/tmp/.esd-1000/socket' - alive cnx 0 errno 0
Socket '/tmp/OSL_PIPE_1000_SingleOfficeIPC_16adf7e8b0d32dc9df645db617f77752' - alive cnx 0 errno 0
Socket '/tmp/keyring-cNhiNs/pkcs11' - alive cnx 0 errno 0
Socket '/tmp/keyring-cNhiNs/control' - alive cnx 0 errno 0
Socket '/tmp/keyring-cNhiNs/ssh' - alive cnx 0 errno 0
Socket '/tmp/keyring-cNhiNs/gpg' - alive cnx 0 errno 0
Socket '/tmp/.X11-unix/X0' - alive cnx 0 errno 0
Socket '/tmp/.ICE-unix/9731' - alive cnx 0 errno 0

-- 
michael.meeks at suse.com  <><, Pseudo Engineer, itinerant idiot


More information about the systemd-devel mailing list