forked from RobotWebTools/roslibjs
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent race condition in TFClient (RobotWebTools#489)
If a TFClient is disposed while a service call to update the goal is ongoing it will subscribe to the republished topic even if none is listening.
- Loading branch information
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
var expect = require('chai').expect; | ||
var ROSLIB = require('..'); | ||
|
||
describe('TFClient', function() { | ||
|
||
describe('dispose', function() { | ||
|
||
it('should not subscribe to republished topic if already disposed', function() { | ||
// This test makes sure we do not subscribe to the republished topic if the | ||
// tf client has already been disposed when we get the response (from the setup request) | ||
// from the server. | ||
|
||
var dummyROS = { | ||
idCounter: 0, | ||
on: () => {}, | ||
off: () => {}, | ||
callOnConnection: () => {} | ||
} | ||
|
||
var tfclient = new ROSLIB.TFClient({ros: dummyROS}); | ||
tfclient.dispose(); | ||
|
||
// Simulated a response from the server after the client is already disposed | ||
tfclient.processResponse({topic_name: "/repub_1"}); | ||
|
||
expect(tfclient.currentTopic).to.be.false; | ||
}); | ||
}); | ||
|
||
}); |