Bug 136219

Summary: Websocket state should be set to closed in didReceiveMessage call back
Product: WebKit Reporter: Shivakumar J M <shiva.jm>
Component: WebCore Misc.Assignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: ap, commit-queue, darin, gyuyoung.kim, kling, ryuan.choi
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
darin: review-, darin: commit-queue-
Patch-Updated none

Description Shivakumar J M 2014-08-25 03:45:48 PDT
According to W3C specification link: http://www.w3.org/TR/websockets/ , Websocket state should be set to closed in didReceiveMessage call back
Comment 1 Shivakumar J M 2014-08-25 04:30:04 PDT
Created attachment 237076 [details]
Patch

Set the Websocket state to closed in didReceiveMessage call back
Comment 2 Darin Adler 2014-08-25 09:42:45 PDT
Comment on attachment 237076 [details]
Patch

WebKit bug fixes require either a test case or an explanation of why they don’t have one. Please add a regression test.
Comment 3 Shivakumar J M 2014-08-26 03:25:31 PDT
Created attachment 237144 [details]
Patch-Updated

Updated patch with new layout test
Comment 4 Darin Adler 2014-08-29 10:09:21 PDT
Comment on attachment 237144 [details]
Patch-Updated

View in context: https://bugs.webkit.org/attachment.cgi?id=237144&action=review

> Source/WebCore/Modules/websockets/WebSocket.cpp:536
> +    m_state = CLOSED;

Do we also need to call m_channel->disconnect()? Do we also need to call ActiveDOMObject::unsetPendingActivity?
Comment 5 Shivakumar J M 2014-09-01 01:25:08 PDT
(In reply to comment #4)
> (From update of attachment 237144 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=237144&action=review
> 
> > Source/WebCore/Modules/websockets/WebSocket.cpp:536
> > +    m_state = CLOSED;
> 
> Do we also need to call m_channel->disconnect()? Do we also need to call ActiveDOMObject::unsetPendingActivity?

Dear Darin,

     Thanks for inputs, i rechecked again, i think we no need to close the channel object here, also ActiveDOMObject.
Comment 6 Darin Adler 2014-09-08 22:45:37 PDT
Comment on attachment 237144 [details]
Patch-Updated

View in context: https://bugs.webkit.org/attachment.cgi?id=237144&action=review

>>> Source/WebCore/Modules/websockets/WebSocket.cpp:536
>>> +    m_state = CLOSED;
>> 
>> Do we also need to call m_channel->disconnect()? Do we also need to call ActiveDOMObject::unsetPendingActivity?
> 
> Dear Darin,
> 
>      Thanks for inputs, i rechecked again, i think we no need to close the channel object here, also ActiveDOMObject.

I’m glad you think so. Why do you think so?
Comment 7 Shivakumar J M 2014-09-09 00:06:46 PDT
(In reply to comment #6)
> (From update of attachment 237144 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=237144&action=review
> 
> >>> Source/WebCore/Modules/websockets/WebSocket.cpp:536
> >>> +    m_state = CLOSED;
> >> 
> >> Do we also need to call m_channel->disconnect()? Do we also need to call ActiveDOMObject::unsetPendingActivity?
> > 
> > Dear Darin,
> > 
> >      Thanks for inputs, i rechecked again, i think we no need to close the channel object here, also ActiveDOMObject.
> 
> I’m glad you think so. Why do you think so?


Dear Darin,

Here is my analysis, When i ran the new test cases error-event-ready-state.html, first we get onerror() call back, where the proper state will be set, after these onclose() will get called, so here the channel object will get closed and ActiveDOMObject as well. so we no need to release the resources in didReceiveMessageError() call back.

I tried by closing channel object in didReceiveMessageError() call back. but it was failing some other tests, with error: FAIL: Timed out waiting for notifyDone to be called.

pls share your inputs, if my understanding is not correct.
Comment 8 Darin Adler 2014-09-14 12:38:22 PDT
Alexey, you know this code better than I do. Could you review?
Comment 9 Alexey Proskuryakov 2014-09-15 17:39:49 PDT
Comment on attachment 237144 [details]
Patch-Updated

The existing code is somewhat confusing, but I think that the patch a step in the right direction.

The key consideration is that there is only one place where an error event is dispatched per the spec, and that's right before a close event.
Comment 10 WebKit Commit Bot 2014-09-15 17:45:12 PDT
Comment on attachment 237144 [details]
Patch-Updated

Clearing flags on attachment: 237144

Committed r173642: <http://trac.webkit.org/changeset/173642>
Comment 11 WebKit Commit Bot 2014-09-15 17:45:18 PDT
All reviewed patches have been landed.  Closing bug.