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 712547 - GSocketClient "event" not useful for determining resolved address
GSocketClient "event" not useful for determining resolved address
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2013-11-17 22:29 UTC by Colin Walters
Modified: 2013-11-18 22:16 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GSocketClient: For _CONNECTING event, make remote address accessible (6.29 KB, patch)
2013-11-18 21:26 UTC, Colin Walters
none Details | Review
GSocketClient: For _CONNECTING event, make remote address accessible (6.31 KB, patch)
2013-11-18 21:30 UTC, Colin Walters
committed Details | Review

Description Colin Walters 2013-11-17 22:29:12 UTC
So in my app "hotssh" I'm using GSocketClient, and I wanted to monitor the connection status.  Like:

Connecting to userinput.example.com...  # No outstanding state
Connecting to userinput.example.com (10.7.42.3)  # After we've resolved address
Connected to userinput.example.com (10.7.42.3) - frobnicating  # After we've connect()ed

I haven't actually done much raw socket stuff with Gio before, but I saw the "event" signal on GSocketClient, and assumed this *had* to be for exactly this use case, and I wrote:

https://git.gnome.org/browse/hotssh/commit/?id=737a9fb2a7fc22878590ce323517277545f365d5

But then I read the glib source when my code didn't work, and yeah...from what I can tell we just don't pass "address" anywhere accessible to the application code before we're actually done attempting the connect() =(

I'd like to not have to enumerate the GSocketConnectable myself and such...

Am I missing something?
Comment 1 Dan Winship 2013-11-18 01:45:23 UTC
Doh. Yeah, this is broken. (The event signal is for several different use cases (bug 665805), but for the "progress message" use case I was thinking in terms of web browsers, where they don't show the IP address to the user, so I never noticed that it wasn't even available.)

It shouldn't break anyone if we added some API so that GSocketClient can set GSocketConnection's remote_address before it's connected. (The only way it could break things is if someone was calling g_socket_connection_get_remote_address() from a GSocketClient::event CONNECTING handler, and then asserting that the result was NULL. Which would be silly.)
Comment 2 Colin Walters 2013-11-18 21:26:01 UTC
Created attachment 260167 [details] [review]
GSocketClient: For _CONNECTING event, make remote address accessible

My application (hotssh) would like to get the resolved address from DNS,
before we start the connect().

Without adding an event (which would be an ABI break of sorts), cache
it on the GSocketConnection.
Comment 3 Colin Walters 2013-11-18 21:30:19 UTC
Created attachment 260168 [details] [review]
GSocketClient: For _CONNECTING event, make remote address accessible

Now with correct entry in Makefile.am
Comment 4 Dan Winship 2013-11-18 21:51:11 UTC
Comment on attachment 260168 [details] [review]
GSocketClient: For _CONNECTING event, make remote address accessible

> gio/gsocketconnection-private.h | 35 +++++++++++++++++++++++++++++++++++

You could use gioprivate.h if you wanted.

>+_g_socket_connection_set_cached_remote_address (GSocketConnection *connection,

You don't need to use a "_" prefix these days, since anything not marked GLIB_AVAILABLE_IN_ won't get exported.

Anyway, good to commit with either of the above changes or not.


oh, and:

> Without adding an event (which would be an ABI break of sorts)

The ::event docs explicitly warn:

   * Note that there may be additional #GSocketClientEvent values in
   * the future; unrecognized @event values should be ignored.
Comment 5 Colin Walters 2013-11-18 22:16:36 UTC
Thanks!  Committed with those fixes, plus some docs.

Attachment 260168 [details] pushed as a46459b - GSocketClient: For _CONNECTING event, make remote address accessible