fix remaining memory leaks

This commit is contained in:
Kevin Jahns
2016-03-23 14:33:51 +01:00
parent 88971b4e69
commit 83a42271ad
5 changed files with 32 additions and 27 deletions

View File

@@ -19,6 +19,8 @@ module.exports = function (Y/* :any */) {
userId: UserId;
send: Function;
broadcast: Function;
broadcastOpBuffer: Array<Operation>;
protocolVersion: number;
*/
/*
opts contains the following information:
@@ -51,7 +53,7 @@ module.exports = function (Y/* :any */) {
this.broadcastedHB = false
this.syncStep2 = Promise.resolve()
this.broadcastOpBuffer = []
this.protocolVersion = 8
this.protocolVersion = 10
}
reconnect () {
}
@@ -150,7 +152,8 @@ module.exports = function (Y/* :any */) {
conn.send(syncUser, {
type: 'sync step 1',
stateSet: stateSet,
deleteSet: deleteSet
deleteSet: deleteSet,
protocolVersion: conn.protocolVersion
})
})
} else {
@@ -234,7 +237,8 @@ module.exports = function (Y/* :any */) {
type: 'sync step 2',
os: ops,
stateSet: currentStateSet,
deleteSet: ds
deleteSet: ds,
protocolVersion: this.protocolVersion
})
if (this.forwardToSyncingClients) {
conn.syncingClients.push(sender)

View File

@@ -182,6 +182,10 @@ g.compareAllUsers = async(function * compareAllUsers (users) {
for (var uid = 0; uid < users.length; uid++) {
var u = users[uid]
u.db.requestTransaction(function * () {
var sv = yield* this.getStateVector()
for (var s of sv) {
yield* this.updateState(s.user)
}
// compare deleted ops against deleteStore
yield* this.os.iterate(this, null, null, function * (o) {
if (o.deleted === true) {

View File

@@ -156,30 +156,19 @@ module.exports = function (Y/* :any */) {
* deleteList (start) {
while (start != null) {
start = yield* this.getOperation(start)
if (start.gc) {
break
} else {
if (!start.gc) {
start.gc = true
start.deleted = true
yield* this.setOperation(start)
yield* this.markDeleted(start.id, 1)
if (start.opContent != null) {
yield* this.deleteOperation(start.opContent)
/*
yield* this.deleteOperation(start.opContent)
var opContent = yield* this.getOperation(start.opContent)
opContent.gc = true
yield* this.setOperation(opContent)
if (this.store.y.connector.isSynced) {
this.store.gc1.push(opContent.id)
}
*/
}
if (this.store.y.connector.isSynced){
this.store.gc1.push(start.id)
}
start = start.right
}
start = start.right
}
}
@@ -561,15 +550,15 @@ module.exports = function (Y/* :any */) {
// so we have to set right here
yield* this.setOperation(right)
}
// o may originate in another operation.
// Since o is deleted, we have to reset o.origin's `originOf` property
if (o.origin != null) {
var origin = yield* this.getOperation(o.origin)
origin.originOf = origin.originOf.filter(function (_id) {
return !Y.utils.compareIds(id, _id)
})
yield* this.setOperation(origin)
}
}
// o may originate in another operation.
// Since o is deleted, we have to reset o.origin's `originOf` property
if (o.origin != null) {
var origin = yield* this.getOperation(o.origin)
origin.originOf = origin.originOf.filter(function (_id) {
return !Y.utils.compareIds(id, _id)
})
yield* this.setOperation(origin)
}
var parent
if (o.parent != null){