Fix sessioninfos race that can cause crash during USER_CHANGES handling

When stress testing etherpad-lite we occasionally got this error:

TypeError: Cannot read property 'author' of undefined
    at /home/etherpad/etherpad-lite/src/node/handler/PadMessageHandler.js:556:47

handleUserChanges was accessing sessioninfos[client.id].author in a callback,
after spending some time in the loop that updates the changeset to the
latest revision. It's possible for a disconnect request to be processed
during that loop so the session might no longer be there.

This patch fixes it by looking up the author at the start of the function.
This commit is contained in:
Richard Braakman 2012-09-26 03:01:53 +03:00
parent 49799bfa97
commit e16008b371

View file

@ -465,6 +465,7 @@ function handleUserChanges(client, message)
var baseRev = message.data.baseRev;
var wireApool = (new AttributePool()).fromJsonable(message.data.apool);
var changeset = message.data.changeset;
var thisAuthor = sessioninfos[client.id].author;
var r, apool, pad;
@ -545,8 +546,6 @@ function handleUserChanges(client, message)
return;
}
var thisAuthor = sessioninfos[client.id].author;
pad.appendRevision(changeset, thisAuthor);
var correctionChangeset = _correctMarkersInPad(pad.atext, pad.pool);