Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(401)

Side by Side Diff: Source/modules/webdatabase/DatabaseThread.cpp

Issue 657023003: Tentative fix of a crash in Oilpan GC after a database thread termination. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2013 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2013 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 // Close the databases that we ran transactions on. This ensures that if any transactions are still open, they are rolled back and we don't leave the databa se in an 107 // Close the databases that we ran transactions on. This ensures that if any transactions are still open, they are rolled back and we don't leave the databa se in an
108 // inconsistent or locked state. 108 // inconsistent or locked state.
109 if (m_openDatabaseSet.size() > 0) { 109 if (m_openDatabaseSet.size() > 0) {
110 // As the call to close will modify the original set, we must take a cop y to iterate over. 110 // As the call to close will modify the original set, we must take a cop y to iterate over.
111 HeapHashSet<Member<Database> > openSetCopy; 111 HeapHashSet<Member<Database> > openSetCopy;
112 openSetCopy.swap(m_openDatabaseSet); 112 openSetCopy.swap(m_openDatabaseSet);
113 HeapHashSet<Member<Database> >::iterator end = openSetCopy.end(); 113 HeapHashSet<Member<Database> >::iterator end = openSetCopy.end();
114 for (HeapHashSet<Member<Database> >::iterator it = openSetCopy.begin(); it != end; ++it) 114 for (HeapHashSet<Member<Database> >::iterator it = openSetCopy.begin(); it != end; ++it)
115 (*it)->close(); 115 (*it)->close();
116 } 116 }
117 m_openDatabaseSet.clear();
117 118
118 m_thread->postTask(new Task(WTF::bind(&DatabaseThread::cleanupDatabaseThread Completed, this))); 119 m_thread->postTask(new Task(WTF::bind(&DatabaseThread::cleanupDatabaseThread Completed, this)));
haraken 2014/10/15 08:20:18 Just help me understand: Why do we need to post th
tkent 2014/10/15 08:41:22 I don't remember the reason. Anyway, it's unrelat
119 } 120 }
120 121
121 void DatabaseThread::cleanupDatabaseThreadCompleted() 122 void DatabaseThread::cleanupDatabaseThreadCompleted()
122 { 123 {
123 m_thread->detachGC(); 124 m_thread->detachGC();
124 if (m_cleanupSync) // Someone wanted to know when we were done cleaning up. 125 if (m_cleanupSync) // Someone wanted to know when we were done cleaning up.
125 m_cleanupSync->taskCompleted(); 126 m_cleanupSync->taskCompleted();
126 } 127 }
127 128
128 void DatabaseThread::recordDatabaseOpen(Database* database) 129 void DatabaseThread::recordDatabaseOpen(Database* database)
129 { 130 {
130 ASSERT(isDatabaseThread()); 131 ASSERT(isDatabaseThread());
131 ASSERT(database); 132 ASSERT(database);
132 ASSERT(!m_openDatabaseSet.contains(database)); 133 ASSERT(!m_openDatabaseSet.contains(database));
133 m_openDatabaseSet.add(database); 134 MutexLocker lock(m_terminationRequestedMutex);
135 if (!m_terminationRequested)
136 m_openDatabaseSet.add(database);
134 } 137 }
135 138
136 void DatabaseThread::recordDatabaseClosed(Database* database) 139 void DatabaseThread::recordDatabaseClosed(Database* database)
137 { 140 {
138 ASSERT(isDatabaseThread()); 141 ASSERT(isDatabaseThread());
139 ASSERT(database); 142 ASSERT(database);
140 ASSERT(m_terminationRequested || m_openDatabaseSet.contains(database)); 143 ASSERT(m_terminationRequested || m_openDatabaseSet.contains(database));
141 m_openDatabaseSet.remove(database); 144 m_openDatabaseSet.remove(database);
haraken 2014/10/15 08:20:18 Don't you need to add a MutexLocker and check !m_t
tkent 2014/10/15 08:41:22 No. This function is supposed to be called after a
tkent 2014/10/15 08:43:47 This HeapHashSet::remove() is harmless even if m_t
142 } 145 }
143 146
144 bool DatabaseThread::isDatabaseOpen(Database* database) 147 bool DatabaseThread::isDatabaseOpen(Database* database)
145 { 148 {
146 ASSERT(isDatabaseThread()); 149 ASSERT(isDatabaseThread());
147 ASSERT(database); 150 ASSERT(database);
148 MutexLocker lock(m_terminationRequestedMutex); 151 MutexLocker lock(m_terminationRequestedMutex);
149 return !m_terminationRequested && m_openDatabaseSet.contains(database); 152 return !m_terminationRequested && m_openDatabaseSet.contains(database);
150 } 153 }
151 154
152 void DatabaseThread::scheduleTask(PassOwnPtr<DatabaseTask> task) 155 void DatabaseThread::scheduleTask(PassOwnPtr<DatabaseTask> task)
153 { 156 {
154 ASSERT(m_thread); 157 ASSERT(m_thread);
155 ASSERT(!terminationRequested()); 158 ASSERT(!terminationRequested());
156 // WebThread takes ownership of the task. 159 // WebThread takes ownership of the task.
157 m_thread->postTask(task.leakPtr()); 160 m_thread->postTask(task.leakPtr());
158 } 161 }
159 162
160 } // namespace blink 163 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698