After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 720482 - old socket dirs are not removed
old socket dirs are not removed
Status: RESOLVED FIXED
Product: gvfs
Classification: Core
Component: daemon
1.18.x
Other OpenBSD
: Normal normal
: ---
Assigned To: gvfs-maint
gvfs-maint
: 547412 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2013-12-15 11:09 UTC by Antoine Jacoutot
Modified: 2014-04-23 07:33 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
remove socket before socket_dir (1.62 KB, patch)
2014-01-21 15:37 UTC, Antoine Jacoutot
needs-work Details | Review
remove socket before socket_dir v2 (1.36 KB, patch)
2014-01-23 13:04 UTC, Antoine Jacoutot
needs-work Details | Review
remove socket before socket_dir v3 (1.37 KB, patch)
2014-01-23 13:42 UTC, Antoine Jacoutot
committed Details | Review

Description Antoine Jacoutot 2013-12-15 11:09:15 UTC
Hi.

It seems gvfs does not clean up its socket directory properly under some circumstances. After a few days running GNOME:
$ find /tmp -type d -name '*gvfs*' | wc -l
      68

They still all contain a socket file like: /tmp/gvfs-username-XXXXXXXX/socket and
some dates from when the laptop was started (i.e. few days ago).

I am running on OpenBSD, I think this is not seen on Linux because of abstract sockets (I may be wrong though).

new_connection_data_free() (daemon/gvfsdaemon.c) has this code:

  /* Remove the socket and dir after connected */
  if (data->socket_dir)
    rmdir (data->socket_dir);

So in case the socket dir is not empty, which is the case here since it contains a socket file, the directory is not removed.
Note that I am not sure this is really where it happens... but well, I would like to find out why these directories do not get removed.

Thank you.
Comment 1 Alexander Larsson 2014-01-20 19:14:11 UTC
Yeah, it seems likely that the problem is just that the rmdir fails due to a non-empty dir.

Can you try just removing socket_dir/socket before the rmdir? That seems like the correct fix to me.
Comment 2 Alexander Larsson 2014-01-21 08:11:06 UTC
In general the code works like this:
* Each gvfs daemon is connected to the session bus.
* Clients connect to the daemon via the session bus, sending a GetConnection
  request when they want to set up a peer-to-peer connection.
* The daemon then creates a unix domain socket and starts up a server on it,
  returning the address over the session bus.
* The client connects to the address
* The daemon deletes the socket as there will be no more users connecting to it.
Comment 3 Antoine Jacoutot 2014-01-21 15:35:46 UTC
> Can you try just removing socket_dir/socket before the rmdir? That seems like
> the correct fix to me.

Hi Alexander.

This patch does the trick for me.
Comment 4 Antoine Jacoutot 2014-01-21 15:37:55 UTC
Created attachment 266889 [details] [review]
remove socket before socket_dir
Comment 5 Antoine Jacoutot 2014-01-23 08:37:25 UTC
Any comments about it? FYI that patch has been applied to the gvfs package in OpenBSD-current to widen the testing and so far everything works as advertised.

Thanks.
Comment 6 Ondrej Holy 2014-01-23 12:41:10 UTC
Review of attachment 266889 [details] [review]:

Thank you for the patch. Just a few notes...

::: daemon/gvfsdaemon.c
@@ +607,2 @@
     rmdir (data->socket_dir);
+    if (socket)

I think the if condition isn't necessary...

@@ +916,3 @@
       rmdir (socket_dir);
+      if (socket)
+        g_free (socket);

Wouldn't be better to use the new_connection_data_free function instead?
Comment 7 Antoine Jacoutot 2014-01-23 13:03:56 UTC
(In reply to comment #6)
> Review of attachment 266889 [details] [review]:
> 
> Thank you for the patch. Just a few notes...
> 
> ::: daemon/gvfsdaemon.c
> @@ +607,2 @@
>      rmdir (data->socket_dir);
> +    if (socket)
> 
> I think the if condition isn't necessary...
> 
> @@ +916,3 @@
>        rmdir (socket_dir);
> +      if (socket)
> +        g_free (socket);
> 
> Wouldn't be better to use the new_connection_data_free function instead?

You are right, that is way better.
New patch attached. Thank you for the review :-)
Comment 8 Antoine Jacoutot 2014-01-23 13:04:18 UTC
Created attachment 267042 [details] [review]
remove socket before socket_dir v2
Comment 9 Ondrej Holy 2014-01-23 13:32:56 UTC
Review of attachment 267042 [details] [review]:

::: daemon/gvfsdaemon.c
@@ +909,1 @@
   g_free (data);

data is freed in new_connection_data_free already...
Comment 10 Antoine Jacoutot 2014-01-23 13:42:03 UTC
Created attachment 267046 [details] [review]
 remove socket before socket_dir v3

*sigh* not my day... Here you go, sorry about that.
Comment 11 Ondrej Holy 2014-01-23 14:12:10 UTC
Comment on attachment 267046 [details] [review]
 remove socket before socket_dir v3

Thanks!

commit 2909ef002746201a83922fdd1c5efad6766347f8
Comment 12 Ondrej Holy 2014-01-23 14:16:46 UTC
gnome-3-10:
commit 21239e01037c6375518e3dbbd8548634b6e500ac
Comment 13 Ross Lagerwall 2014-04-23 07:33:09 UTC
*** Bug 547412 has been marked as a duplicate of this bug. ***