mirror of
https://github.com/openstf/stf
synced 2025-10-05 02:29:26 +02:00
Reset owner and reverse forwards when a dead worker restarts. This should prevent ghost owners from staying in the device list.
This commit is contained in:
parent
fe7785f003
commit
4a4b0f26d1
5 changed files with 24 additions and 9 deletions
|
@ -243,16 +243,18 @@ dbapi.setDeviceReverseForwards = function(serial, forwards) {
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
dbapi.setDeviceChannel = function(serial, channel) {
|
dbapi.setDeviceReady = function(serial, channel) {
|
||||||
return db.run(r.table('devices').get(serial).update({
|
return db.run(r.table('devices').get(serial).update({
|
||||||
channel: channel
|
channel: channel
|
||||||
|
, ready: true
|
||||||
|
, owner: null
|
||||||
|
, reverseForwards: []
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
dbapi.saveDeviceIdentity = function(serial, identity) {
|
dbapi.saveDeviceIdentity = function(serial, identity) {
|
||||||
return db.run(r.table('devices').get(serial).update({
|
return db.run(r.table('devices').get(serial).update({
|
||||||
ready: true
|
platform: identity.platform
|
||||||
, platform: identity.platform
|
|
||||||
, manufacturer: identity.manufacturer
|
, manufacturer: identity.manufacturer
|
||||||
, operator: identity.operator
|
, operator: identity.operator
|
||||||
, model: identity.model
|
, model: identity.model
|
||||||
|
|
|
@ -51,7 +51,7 @@ module.exports = syrup.serial()
|
||||||
, poke: function() {
|
, poke: function() {
|
||||||
push.send([
|
push.send([
|
||||||
wireutil.global
|
wireutil.global
|
||||||
, wireutil.envelope(new wire.DevicePokeMessage(
|
, wireutil.envelope(new wire.DeviceReadyMessage(
|
||||||
options.serial
|
options.serial
|
||||||
, channel
|
, channel
|
||||||
))
|
))
|
||||||
|
|
|
@ -83,13 +83,15 @@ module.exports = function(options) {
|
||||||
appDealer.send([channel, data])
|
appDealer.send([channel, data])
|
||||||
})
|
})
|
||||||
// Worker initialized
|
// Worker initialized
|
||||||
.on(wire.DevicePokeMessage, function(channel, message) {
|
.on(wire.DeviceReadyMessage, function(channel, message, data) {
|
||||||
dbapi.setDeviceChannel(message.serial, message.channel)
|
dbapi.setDeviceReady(message.serial, message.channel)
|
||||||
.then(function() {
|
.then(function() {
|
||||||
devDealer.send([
|
devDealer.send([
|
||||||
message.channel
|
message.channel
|
||||||
, wireutil.envelope(new wire.ProbeMessage())
|
, wireutil.envelope(new wire.ProbeMessage())
|
||||||
])
|
])
|
||||||
|
|
||||||
|
appDealer.send([channel, data])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
// Worker messages
|
// Worker messages
|
||||||
|
|
|
@ -134,6 +134,18 @@ module.exports = function(options) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
.on(wire.DeviceReadyMessage, function(channel, message) {
|
||||||
|
socket.emit('device.change', {
|
||||||
|
important: true
|
||||||
|
, data: {
|
||||||
|
serial: message.serial
|
||||||
|
, channel: message.channel
|
||||||
|
, owner: null // @todo Get rid of need to reset this here.
|
||||||
|
, ready: true
|
||||||
|
, reverseForwards: [] // @todo Get rid of need to reset this here.
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
.on(wire.DevicePresentMessage, function(channel, message) {
|
.on(wire.DevicePresentMessage, function(channel, message) {
|
||||||
socket.emit('device.change', {
|
socket.emit('device.change', {
|
||||||
important: true
|
important: true
|
||||||
|
@ -192,7 +204,6 @@ module.exports = function(options) {
|
||||||
})
|
})
|
||||||
.on(wire.DeviceIdentityMessage, function(channel, message) {
|
.on(wire.DeviceIdentityMessage, function(channel, message) {
|
||||||
datautil.applyData(message)
|
datautil.applyData(message)
|
||||||
message.ready = true
|
|
||||||
socket.emit('device.change', {
|
socket.emit('device.change', {
|
||||||
important: true
|
important: true
|
||||||
, data: message
|
, data: message
|
||||||
|
|
|
@ -7,7 +7,7 @@ enum MessageType {
|
||||||
DeviceIdentityMessage = 2;
|
DeviceIdentityMessage = 2;
|
||||||
DeviceLogcatEntryMessage = 3;
|
DeviceLogcatEntryMessage = 3;
|
||||||
DeviceLogMessage = 4;
|
DeviceLogMessage = 4;
|
||||||
DevicePokeMessage = 5;
|
DeviceReadyMessage = 5;
|
||||||
DevicePresentMessage = 6;
|
DevicePresentMessage = 6;
|
||||||
DevicePropertiesMessage = 7;
|
DevicePropertiesMessage = 7;
|
||||||
DeviceRegisteredMessage = 8;
|
DeviceRegisteredMessage = 8;
|
||||||
|
@ -136,7 +136,7 @@ message DeviceAbsentMessage {
|
||||||
required string serial = 1;
|
required string serial = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message DevicePokeMessage {
|
message DeviceReadyMessage {
|
||||||
required string serial = 1;
|
required string serial = 1;
|
||||||
required string channel = 2;
|
required string channel = 2;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue