<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>173739</bug_id>
          
          <creation_ts>2017-06-22 15:16:03 -0700</creation_ts>
          <short_desc>LibWebRTCSocketClient should not destroy its socket within signalClose callback</short_desc>
          <delta_ts>2017-06-23 13:43:46 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Media</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="youenn fablet">youennf</reporter>
          <assigned_to name="youenn fablet">youennf</assigned_to>
          <cc>achristensen</cc>
    
    <cc>bfulgham</cc>
    
    <cc>commit-queue</cc>
    
    <cc>ddkilzer</cc>
    
    <cc>eric.carlson</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1322082</commentid>
    <comment_count>0</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2017-06-22 15:16:03 -0700</bug_when>
    <thetext>LibWebRTCSocketClient should not destroy its socket within signalClose callback</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1322083</commentid>
    <comment_count>1</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2017-06-22 15:16:17 -0700</bug_when>
    <thetext>rdar://problem/32922877</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1322088</commentid>
    <comment_count>2</comment_count>
      <attachid>313666</attachid>
    <who name="youenn fablet">youennf</who>
    <bug_when>2017-06-22 15:23:45 -0700</bug_when>
    <thetext>Created attachment 313666
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1322305</commentid>
    <comment_count>3</comment_count>
      <attachid>313666</attachid>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2017-06-23 09:21:32 -0700</bug_when>
    <thetext>Comment on attachment 313666
Patch

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

&gt; Source/WebKit2/NetworkProcess/webrtc/LibWebRTCSocketClient.cpp:141
&gt; +    m_rtcProvider.callOnRTCNetworkThread([socket = m_rtcProvider.takeSocket(m_identifier)] { });

How do we know this is sufficient lifespan? I don&apos;t think that anything really guarantees that the RTCNetworkThread doesn&apos;t wake up and do the destruction before the caller of LibWebRTCSocketClient::signalClose() has a chance to finish using the socket. It seems like the caller needs some way to keep &apos;socket&apos; alive for as long as it needs to use it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1322307</commentid>
    <comment_count>4</comment_count>
      <attachid>313666</attachid>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2017-06-23 09:24:29 -0700</bug_when>
    <thetext>Comment on attachment 313666
Patch

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

r=me

&gt;&gt; Source/WebKit2/NetworkProcess/webrtc/LibWebRTCSocketClient.cpp:141
&gt;&gt; +    m_rtcProvider.callOnRTCNetworkThread([socket = m_rtcProvider.takeSocket(m_identifier)] { });
&gt; 
&gt; How do we know this is sufficient lifespan? I don&apos;t think that anything really guarantees that the RTCNetworkThread doesn&apos;t wake up and do the destruction before the caller of LibWebRTCSocketClient::signalClose() has a chance to finish using the socket. It seems like the caller needs some way to keep &apos;socket&apos; alive for as long as it needs to use it.

Looking further, I guess the only caller of LibWebRTCSocketClient::signalClose is the WebRTCSocket message handler, which calls this method and doesn&apos;t do anything else.

We might have a number of queued up messages to be handled that need socket, but by putting the destruction in the message queue, we guarantee that those tasks are done by the time we are allowed to destroy the socket.

So I&apos;m confident this change is correct.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1322321</commentid>
    <comment_count>5</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2017-06-23 09:45:48 -0700</bug_when>
    <thetext>(In reply to Brent Fulgham from comment #4)
&gt; Comment on attachment 313666 [details]
&gt; Patch
&gt; 
&gt; View in context:
&gt; https://bugs.webkit.org/attachment.cgi?id=313666&amp;action=review
&gt; 
&gt; r=me
&gt; 
&gt; &gt;&gt; Source/WebKit2/NetworkProcess/webrtc/LibWebRTCSocketClient.cpp:141
&gt; &gt;&gt; +    m_rtcProvider.callOnRTCNetworkThread([socket = m_rtcProvider.takeSocket(m_identifier)] { });
&gt; &gt; 
&gt; &gt; How do we know this is sufficient lifespan? I don&apos;t think that anything really guarantees that the RTCNetworkThread doesn&apos;t wake up and do the destruction before the caller of LibWebRTCSocketClient::signalClose() has a chance to finish using the socket. It seems like the caller needs some way to keep &apos;socket&apos; alive for as long as it needs to use it.
&gt; 
&gt; Looking further, I guess the only caller of
&gt; LibWebRTCSocketClient::signalClose is the WebRTCSocket message handler,
&gt; which calls this method and doesn&apos;t do anything else.
&gt; 
&gt; We might have a number of queued up messages to be handled that need socket,
&gt; but by putting the destruction in the message queue, we guarantee that those
&gt; tasks are done by the time we are allowed to destroy the socket.
&gt; 
&gt; So I&apos;m confident this change is correct.

Right, maybe I should beef up the change log?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1322410</commentid>
    <comment_count>6</comment_count>
      <attachid>313666</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2017-06-23 13:43:45 -0700</bug_when>
    <thetext>Comment on attachment 313666
Patch

Clearing flags on attachment: 313666

Committed r218759: &lt;http://trac.webkit.org/changeset/218759&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1322411</commentid>
    <comment_count>7</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2017-06-23 13:43:46 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>313666</attachid>
            <date>2017-06-22 15:23:45 -0700</date>
            <delta_ts>2017-06-23 13:43:45 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-173739-20170622152344.patch</filename>
            <type>text/plain</type>
            <size>1907</size>
            <attacher name="youenn fablet">youennf</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjE4Njk1CmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViS2l0Mi9D
aGFuZ2VMb2cgYi9Tb3VyY2UvV2ViS2l0Mi9DaGFuZ2VMb2cKaW5kZXggNDYyNDg2NjlmMDI5NWUz
NzEzODU1NWM5OTk0MjJkZTc0M2E2NGNjNy4uNjMwZTdiZGRhNDA1MzQ1Y2I1NGNlNzFiNGM5ZTY1
ZDQ5ZGI3MzAxZSAxMDA2NDQKLS0tIGEvU291cmNlL1dlYktpdDIvQ2hhbmdlTG9nCisrKyBiL1Nv
dXJjZS9XZWJLaXQyL0NoYW5nZUxvZwpAQCAtMSwzICsxLDEzIEBACisyMDE3LTA2LTIyICBZb3Vl
bm4gRmFibGV0ICA8eW91ZW5uQGFwcGxlLmNvbT4KKworICAgICAgICBMaWJXZWJSVENTb2NrZXRD
bGllbnQgc2hvdWxkIG5vdCBkZXN0cm95IGl0cyBzb2NrZXQgd2l0aGluIHNpZ25hbENsb3NlIGNh
bGxiYWNrCisgICAgICAgIGh0dHBzOi8vYnVncy53ZWJraXQub3JnL3Nob3dfYnVnLmNnaT9pZD0x
NzM3MzkKKworICAgICAgICBSZXZpZXdlZCBieSBOT0JPRFkgKE9PUFMhKS4KKworICAgICAgICAq
IE5ldHdvcmtQcm9jZXNzL3dlYnJ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