Title: [227045] branches/safari-605-branch/Source/WebCore

Diff

Modified: branches/safari-605-branch/Source/WebCore/ChangeLog (227044 => 227045)


--- branches/safari-605-branch/Source/WebCore/ChangeLog	2018-01-17 05:05:11 UTC (rev 227044)
+++ branches/safari-605-branch/Source/WebCore/ChangeLog	2018-01-17 05:05:13 UTC (rev 227045)
@@ -1,5 +1,29 @@
 2018-01-16  Jason Marcell  <[email protected]>
 
+        Cherry-pick r227010. rdar://problem/36567991
+
+    2018-01-16  Chris Dumez  <[email protected]>
+
+            SWServerWorker::m_contextConnectionIdentifier may get out of date
+            https://bugs.webkit.org/show_bug.cgi?id=181687
+            <rdar://problem/36548111>
+
+            Reviewed by Brady Eidson.
+
+            SWServerWorker::m_contextConnectionIdentifier may get out of date. This happens when the
+            context process crashes and is relaunched.
+
+            No new tests, added assertion in terminateWorkerInternal() that hits without this fix.
+
+            * workers/service/server/SWServer.cpp:
+            (WebCore::SWServer::runServiceWorker):
+            (WebCore::SWServer::terminateWorkerInternal):
+            (WebCore::SWServer::unregisterServiceWorkerClient):
+            * workers/service/server/SWServerWorker.h:
+            (WebCore::SWServerWorker::setContextConnectionIdentifier):
+
+2018-01-16  Jason Marcell  <[email protected]>
+
         Cherry-pick r226916. rdar://problem/36568057
 
     2018-01-11  Dean Jackson  <[email protected]>

Modified: branches/safari-605-branch/Source/WebCore/workers/service/server/SWServer.cpp (227044 => 227045)


--- branches/safari-605-branch/Source/WebCore/workers/service/server/SWServer.cpp	2018-01-17 05:05:11 UTC (rev 227044)
+++ branches/safari-605-branch/Source/WebCore/workers/service/server/SWServer.cpp	2018-01-17 05:05:13 UTC (rev 227045)
@@ -539,6 +539,11 @@
 
     auto* connection = SWServerToContextConnection::globalServerToContextConnection();
     ASSERT(connection);
+
+    // When re-running a service worker after a context process crash, the connection identifier may have changed
+    // so we update it here.
+    worker->setContextConnectionIdentifier(connection->identifier());
+
     connection->installServiceWorkerContext(worker->contextData(), m_sessionID);
 
     return true;
@@ -556,7 +561,10 @@
 
 void SWServer::terminateWorkerInternal(SWServerWorker& worker, TerminationMode mode)
 {
+    ASSERT(worker.isRunning());
+
     auto* connection = SWServerToContextConnection::connectionForIdentifier(worker.contextConnectionIdentifier());
+    ASSERT(connection);
     if (!connection) {
         LOG_ERROR("Request to terminate a worker whose context connection does not exist");
         return;
@@ -737,7 +745,7 @@
         ASSERT(!iterator->value.terminateServiceWorkersTimer);
         iterator->value.terminateServiceWorkersTimer = std::make_unique<Timer>([clientOrigin, this] {
             for (auto& worker : m_runningOrTerminatingWorkers.values()) {
-                if (worker->origin() == clientOrigin)
+                if (worker->isRunning() && worker->origin() == clientOrigin)
                     terminateWorker(worker);
             }
             m_clientIdentifiersPerOrigin.remove(clientOrigin);

Modified: branches/safari-605-branch/Source/WebCore/workers/service/server/SWServerWorker.h (227044 => 227045)


--- branches/safari-605-branch/Source/WebCore/workers/service/server/SWServerWorker.h	2018-01-17 05:05:11 UTC (rev 227044)
+++ branches/safari-605-branch/Source/WebCore/workers/service/server/SWServerWorker.h	2018-01-17 05:05:13 UTC (rev 227045)
@@ -77,7 +77,9 @@
     WorkerType type() const { return m_data.type; }
 
     ServiceWorkerIdentifier identifier() const { return m_data.identifier; }
+
     SWServerToContextConnectionIdentifier contextConnectionIdentifier() const { return m_contextConnectionIdentifier; }
+    void setContextConnectionIdentifier(SWServerToContextConnectionIdentifier identifier) { m_contextConnectionIdentifier = identifier; }
 
     ServiceWorkerState state() const { return m_data.state; }
     void setState(ServiceWorkerState);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to