[Webkit-unassigned] [Bug 134042] Don't kill the UIProcess until all local storage transactions have been committed

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Jun 18 22:36:05 PDT 2014


https://bugs.webkit.org/show_bug.cgi?id=134042





--- Comment #4 from Roger Fong <roger_fong at apple.com>  2014-06-18 22:36:27 PST ---
(In reply to comment #3)
> (From update of attachment 233330 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=233330&action=review
> 
> > Source/WebKit2/UIProcess/WebContext.cpp:723
> > +void WebContext::closeConnectionsInResponseToQuit()
> 
> I think calling this applicationWillTerminate is better.
> 
> > Source/WebKit2/UIProcess/Storage/StorageManager.cpp:611
> > +void StorageManager::closeConnectionsInResponseToQuit()
> > +{
> > +    Vector<std::pair<RefPtr<IPC::Connection>, uint64_t>> connectionAndStorageMapIDPairsToRemove;
> > +    HashMap<std::pair<RefPtr<IPC::Connection>, uint64_t>, RefPtr<StorageArea>> storageAreasByConnection = m_storageAreasByConnection;
> > +    for (HashMap<std::pair<RefPtr<IPC::Connection>, uint64_t>, RefPtr<StorageArea>>::const_iterator it = storageAreasByConnection.begin(), end = storageAreasByConnection.end(); it != end; ++it) {
> > +        it->value->removeListener(it->key.first.get(), it->key.second);
> > +        connectionAndStorageMapIDPairsToRemove.append(it->key);
> > +    }
> > +
> > +    for (size_t i = 0; i < connectionAndStorageMapIDPairsToRemove.size(); ++i)
> > +        m_storageAreasByConnection.remove(connectionAndStorageMapIDPairsToRemove[i]);
> > +
> > +    m_closeMutex.unlock();
> > +}
> 
> How is this ensuring that everything is written to disk?
> 
> > Source/WebKit2/UIProcess/Storage/StorageManager.h:115
> > +    std::mutex m_closeMutex;
> 
> A mutex is the wrong synchronization primitive here. You should use a BinarySemaphore instead. For example, StorageManager::applicationWillTerminate() could do something like:
> 
> void StorageManager::applicationWillTerminate()
> {
>     BinarySemaphore semaphore;
>     m_queue->dispatch([this, &semaphore]) {
>         // Do cleanup work.
>         semaphore.signal();
>     });
> 
>     semaphore.wait();

Would it not make sense, in addition to the semaphore, to use a mutex with the background thread to make sure that closeConnectionsInResponseToQuit and invalidateConnectionInternal don't modify the m_storageAreasByConnection map at the same time?

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list