Bug 28838

Summary: [PATCH] sysdeps-unix: enable address reuse on TCP sockets
Product: dbus Reporter: Steffen Sledz <sledz>
Component: coreAssignee: Havoc Pennington <hp>
Status: RESOLVED FIXED QA Contact: John (J5) Palmieri <johnp>
Severity: enhancement    
Priority: medium CC: freedesktop-bugs, walters
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: 0001-sysdeps-unix-enable-address-reuse-on-TCP-sockets.patch
0001-sysdeps-unix-enable-address-reuse-on-TCP-sockets.patch v2
change to warning
fix Werror in order to test the previous patch

Description Steffen Sledz 2010-06-29 23:40:39 UTC
This helps to avoid 'Address already in use' problems if server has been shut
down, and then restarted while sockets are still active on its port.
Comment 1 Steffen Sledz 2010-06-29 23:42:05 UTC
Created attachment 36620 [details] [review]
0001-sysdeps-unix-enable-address-reuse-on-TCP-sockets.patch
Comment 2 Colin Walters 2010-07-08 07:18:47 UTC
As far as I understand this is almost always the right thing to do for server sockets.  GSocket exposes this as an option, but that's because a GSocket can be either a server or client.  So let's go with this.

I stripped trailing whitespace from your patch and pushed to dbus-1.2.  (This branch will at some point be merged into master)

commit 8f5f340b77b51fed1f036a9ee9f70a31b201f2c9
Author: Sledz <sledz@MOBIL-400-586.intern.dresearch.de>
Date:   Tue Jun 29 23:04:15 2010 +0200

    sysdeps-unix: enable address reuse on TCP sockets
Comment 3 Thomas Themel 2010-08-31 02:53:31 UTC
*** Bug 29889 has been marked as a duplicate of this bug. ***
Comment 4 Havoc Pennington 2010-08-31 06:02:12 UTC
Looks buggy because it sets error but then continues, potentially piling up two errors (which will assert). If you want to continue if setting this option fails, then don't set the error. If you want to fail the socket open entirely when setsockopt fails, you need to close fd and "goto failed." But it's never right to set error and then continue to other things that may also try to "pile up" an additional error.
DBusError (like GError or thrown exceptions) is always fatal to the current operation.
Comment 5 Steffen Sledz 2010-08-31 06:20:00 UTC
Created attachment 38332 [details] [review]
0001-sysdeps-unix-enable-address-reuse-on-TCP-sockets.patch v2

I attached a new version of the patch which treats the problems just as a warning and does not set an error.
Comment 6 Havoc Pennington 2010-08-31 07:10:30 UTC
Comment on attachment 38332 [details] [review]
0001-sysdeps-unix-enable-address-reuse-on-TCP-sockets.patch v2

Looks good!
Comment 7 Steffen Sledz 2010-08-31 07:15:00 UTC
> Looks good!

Can you push the patch than. I'm not allowed to do this.
Comment 8 Havoc Pennington 2010-08-31 09:02:12 UTC
Created attachment 38333 [details] [review]
change to warning

Fix to be a warning.
Comment 9 Havoc Pennington 2010-08-31 09:02:38 UTC
Created attachment 38334 [details] [review]
fix Werror in order to test the previous patch
Comment 10 Havoc Pennington 2010-08-31 09:03:14 UTC
My dbus checkout seems to be anongit, I think freedesktop may have nuked my ssh key a year or two ago, I forget what happened. anyhow here are the ready-to-apply patches.
Comment 11 Lennart Poettering 2010-09-06 10:32:45 UTC
Applied for the 1.4.0 release.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.