Signed-off-by: Hans Leidekker hans@codeweavers.com --- dlls/mshtml/htmlstorage.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/dlls/mshtml/htmlstorage.c b/dlls/mshtml/htmlstorage.c index 502eb8c25ab..1793cfae184 100644 --- a/dlls/mshtml/htmlstorage.c +++ b/dlls/mshtml/htmlstorage.c @@ -191,9 +191,21 @@ static WCHAR *build_filename(const WCHAR *hostname) return ret; }
+static WCHAR *build_mutexname(const WCHAR *filename) +{ + WCHAR *ret, *ptr; + ret = wcsdup(filename); + if(!ret) + return NULL; + for(ptr = ret; *ptr; ptr++) + if(*ptr == '\') *ptr = '_'; + return ret; +} + struct storage { WCHAR *filename; IXMLDOMDocument *doc; + HANDLE mutex; };
static void close_storage(struct storage *storage) @@ -201,6 +213,8 @@ static void close_storage(struct storage *storage) free(storage->filename); if(storage->doc) IXMLDOMDocument_Release(storage->doc); + ReleaseMutex(storage->mutex); + CloseHandle(storage->mutex); free(storage); }
@@ -210,7 +224,7 @@ static HRESULT open_storage(const WCHAR *hostname, struct storage **ret) HRESULT hres = E_OUTOFMEMORY; VARIANT var; VARIANT_BOOL success; - WCHAR *ptr; + WCHAR *mutexname, *ptr;
storage = calloc(1, sizeof(*storage)); if(!storage) @@ -220,6 +234,18 @@ static HRESULT open_storage(const WCHAR *hostname, struct storage **ret) if(!storage->filename) goto done;
+ mutexname = build_mutexname(storage->filename); + if(!mutexname) + goto done; + + storage->mutex = CreateMutexW(NULL, FALSE, mutexname); + free(mutexname); + if(!storage->mutex) { + hres = HRESULT_FROM_WIN32(GetLastError()); + goto done; + } + WaitForSingleObject(storage->mutex, INFINITE); + *(ptr = wcsrchr(storage->filename, '\')) = 0; if(!create_path(storage->filename)) { hres = E_FAIL;