-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dbus: add an external param
waitOnDelay
to handle service unavailable
Sometimes the D-Bus service is unavailable at bootstraping the os, so the client will get a connection with NULL, and the following operations with this connection would make failures even abortions. This patch intros a synchronous wait, that the user could gives a max timeout, within that, ShadowNode attempts to connect and check the following errors: - org.freedesktop.DBus.Error.FileNotFound - org.freedesktop.DBus.Error.Failed If one of them, client would sleep 100ms and retry until the current time is over the given max timeout. Otherwise it breaks the loop for other errors like "Address does not contain a colon".
- Loading branch information
Showing
6 changed files
with
84 additions
and
15 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
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,13 @@ | ||
'use strict'; | ||
|
||
var assert = require('assert'); | ||
var dbus = require('dbus'); | ||
var start = Date.now(); | ||
|
||
try { | ||
dbus.getBus(); | ||
} catch (err) { | ||
console.log(err.message); | ||
assert.equal(err.message, 'Address does not contain a colon'); | ||
} | ||
assert.equal(Date.now() - start < 100, true); |
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,17 @@ | ||
'use strict'; | ||
|
||
var assert = require('assert'); | ||
var dbus = require('dbus'); | ||
|
||
var start = Date.now(); | ||
try { | ||
dbus.getBus(); | ||
} catch (err) { | ||
console.log(err.message); | ||
assert.equal(err.message, | ||
'Failed to connect to socket /invalid: No such file or directory'); | ||
} | ||
|
||
var diff = Date.now() - start; | ||
console.log(`consumes ${diff}ms`); | ||
assert.equal(diff > 1000, true); |
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