[whatwg] localStorage + worker processes

Aaron Boodman aa at google.com
Sat Mar 21 15:25:05 PDT 2009


On Sat, Mar 21, 2009 at 1:51 PM, Jonas Sicking <jonas at sicking.cc> wrote:
> The problem with synchronously grabbing the lock is that we can only
> ever have one feature that uses synchronous locks, otherwise we'll
> risk dead-locks.
>
> Say that we make document.cookie behave the same way (to prevent
> multi-process browsers like IE8 and chrome from having race
> conditions). So that if you call document.getCookiesWithLock(callback)
> we'll synchronously grab a lock and call the callback function. This
> would cause two pages like the ones below to potentially deadlock:
>
> Page 1:
> getLocalStorage(function(storage) {
>  document.getCookiesWithLock(function(cookieContainer) {
>    storage.foo = cookieContainer.getCookie('cookieName');
>  });
> ]);
>
> Page 2:
> document.getCookiesWithLock(function(cookieContainer) {
>  getLocalStorage(function(storage) {
>    cookieContainer.setCookie('cookieName', storage.bar);
>  });
> });

Good point. Ok, I agree that an asynchronous callback makes most sense
for this API.

- a


More information about the whatwg mailing list