WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
45197
[GTK] Need a WebSocket implementation
https://bugs.webkit.org/show_bug.cgi?id=45197
Summary
[GTK] Need a WebSocket implementation
Martin Robinson
Reported
2010-09-03 13:44:23 PDT
This should be fairly easy to implement using GIO.
Attachments
Add WebSocket support
(17.56 KB, patch)
2010-09-03 15:35 PDT
,
Martin Robinson
no flags
Details
Formatted Diff
Diff
Patch with Dan's suggestions
(17.75 KB, patch)
2010-09-07 12:33 PDT
,
Martin Robinson
no flags
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Martin Robinson
Comment 1
2010-09-03 15:35:00 PDT
Created
attachment 66558
[details]
Add WebSocket support
Xan Lopez
Comment 2
2010-09-05 10:28:28 PDT
Comment on
attachment 66558
[details]
Add WebSocket support The only comment I have is why the socket source is created and stored at connection time if it's not going to be necessarily used (?). Or is writing less data than what we have in platformSend so common that it's worth to do things that way?
Martin Robinson
Comment 3
2010-09-06 08:41:51 PDT
(In reply to
comment #2
)
> (From update of
attachment 66558
[details]
) > The only comment I have is why the socket source is created and stored at connection time if it's not going to be necessarily used (?).
Hmm. The GIO documentation seemed unclear about whether or not the reference to the GSocketClient needed to stick around until the connection was finished, so I figured it was safer to keep the reference until it was definitely unused.
> Or is writing less data than what we have in platformSend so common that it's worth to do things that way?
Yeah, we have to handle this. It also presents a good opportunity to start waiting for socket writability. It turns out that if you don't only do this when you need to, the GSource fires continuously and eats up all of your cycles.
Dan Winship
Comment 4
2010-09-07 11:09:01 PDT
Comment on
attachment 66558
[details]
Add WebSocket support
> + PlatformRefPtr<GSocketClient> m_socketClient;
you don't actually need to keep it around; all gio async ops hold a ref on the "source" object for the duration of the async op
> + PlatformRefPtr<GSocketConnectable> address = g_network_address_new(url.host().utf8().data(), port); > + g_socket_client_connect_async(m_socketClient.get(), address.get(), 0, > + reinterpret_cast<GAsyncReadyCallback>(connectedCallback), this);
Use g_socket_client_connect_to_host_async() here, then you don't need to create the temporary GNetworkAddress
> +void SocketStreamHandle::stopWaitingForSocketWritability() > +{ > + if (!m_writeReadySource || !m_waitingForSocketWritability) > + return; > + g_source_remove(g_source_get_id(m_writeReadySource.get()));
That's equivalent to "g_source_destroy(m_writeReadySource.get());". In both cases, you can't use the source again after doing that...
> +static gboolean writeReadyCallback(GSocket*, GIOCondition condition, SocketStreamHandle* handle) > +{ > + if (!isActiveHandle(handle)) > + return FALSE; > + if (condition & G_IO_OUT) > + handle->writeReady(); > + return TRUE; > +}
You should check if "condition & (G_IO_ERR | G_IO_HUP)" is set, and fail the connection (and return FALSE) in that case.
Dan Winship
Comment 5
2010-09-07 11:11:33 PDT
higher-level comment; the ickiness on the write end could be removed if the base API were changed to have a "didSend()" call instead of (or even in addition to) sendPending().
Martin Robinson
Comment 6
2010-09-07 12:33:32 PDT
Created
attachment 66751
[details]
Patch with Dan's suggestions
Martin Robinson
Comment 7
2010-09-07 12:35:46 PDT
(In reply to
comment #5
) Thanks Dan! I've attached a patch with your suggestions. One variation I made was that when the writability callback gets G_IO_HUP, it just calls ::close() on the SocketStreamHandle.
> higher-level comment; the ickiness on the write end could be removed if the base API were changed to have a "didSend()" call instead of (or even in addition to) sendPending().
I agree strongly with this.
Xan Lopez
Comment 8
2010-09-08 02:27:03 PDT
Comment on
attachment 66751
[details]
Patch with Dan's suggestions Let's do this.
Martin Robinson
Comment 9
2010-09-08 08:27:26 PDT
Comment on
attachment 66751
[details]
Patch with Dan's suggestions Clearing flags on attachment: 66751 Committed
r66986
: <
http://trac.webkit.org/changeset/66986
>
Martin Robinson
Comment 10
2010-09-08 08:27:30 PDT
All reviewed patches have been landed. Closing bug.
WebKit Review Bot
Comment 11
2010-09-08 09:31:04 PDT
http://trac.webkit.org/changeset/66986
might have broken GTK Linux 64-bit Debug The following changes are on the blame list:
http://trac.webkit.org/changeset/66985
http://trac.webkit.org/changeset/66986
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug