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 780875 - gsocket: Add support for setting TCP keepalive timeout and interval
gsocket: Add support for setting TCP keepalive timeout and interval
Status: RESOLVED OBSOLETE
Product: glib
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2017-04-03 15:45 UTC by Christophe Fergeau
Modified: 2018-05-24 19:28 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gsocket: Add support for setting TCP keepalive timeout and interval (12.36 KB, patch)
2017-04-03 15:45 UTC, Christophe Fergeau
none Details | Review
gsocket: Add support for setting TCP keepalive timeout and interval (12.45 KB, patch)
2017-04-06 12:32 UTC, Christophe Fergeau
none Details | Review

Description Christophe Fergeau 2017-04-03 15:45:24 UTC
GSocket currently allows to enable/disable sending of TCP keepalives,
but offers no way of changing the interval before keepalive probes are
sent, nor the interval between these probes.

This commit adds
- g_socket_set_keepalive_timeout
- g_socket_get_keepalive_timeout
- g_socket_set_keepalive_interval
- g_socket_get_keepalive_interval

to deal with this. Not all platforms support it, though
Linux/Windows/OSX/recent BSDs should be fine.
Windows support is a bit more limited as the values cannot be read, only
set, and can only enable keepalive/set a timeout and an interval all at
once.
Comment 1 Christophe Fergeau 2017-04-03 15:45:30 UTC
Created attachment 349186 [details] [review]
gsocket: Add support for setting TCP keepalive timeout and interval
Comment 2 Dan Winship 2017-04-03 17:40:00 UTC
What are you doing that you feel this would be useful for? Last time we talked about keepalive the consensus was that it was a mistake to have exposed even SO_KEEPALIVE, because most servers have application-layer timeouts that aren't affected by SO_KEEPALIVE.
Comment 3 Christophe Fergeau 2017-04-04 06:56:16 UTC
Main rationale would be https://lists.freedesktop.org/archives/spice-devel/2017-March/036553.html , ie detect dead SPICE connections without having to wait for 2 hours.
After working on this patch, I realized we'd also need some application-layer pings to keep connections alive (having issues with squid read_timeout setting), so I see your point/the consensus.
This code can easily live in spice-gtk if it's considered out of scope for glib.
Comment 4 Christophe Fergeau 2017-04-06 12:32:49 UTC
Created attachment 349361 [details] [review]
gsocket: Add support for setting TCP keepalive timeout and interval

GSocket currently allows to enable/disable sending of TCP keepalives,
but offers no way of changing the interval before keepalive probes are
sent, nor the interval between these probes.

This commit adds
- g_socket_set_keepalive_timeout
- g_socket_get_keepalive_timeout
- g_socket_set_keepalive_interval
- g_socket_get_keepalive_interval

to deal with this. Not all platforms support it, though
Linux/Windows/OSX/recent BSDs should be fine.
Windows support is a bit more limited as the values cannot be read, only
set, and can only enable keepalive/set a timeout and an interval all at
once.
Comment 5 Christophe Fergeau 2017-04-06 12:37:11 UTC
This version is very similar to the previous one except that it was compile-tested with mingw this time.
Comment 6 GNOME Infrastructure Team 2018-05-24 19:28:29 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/1255.