|
|
|
@ -89,7 +89,7 @@ function _dhtgetAbortPending(locator)
@@ -89,7 +89,7 @@ function _dhtgetAbortPending(locator)
|
|
|
|
|
// get data from dht resource
|
|
|
|
|
// the value ["v"] is extracted from response and returned to callback
|
|
|
|
|
// null is passed to callback in case of an error
|
|
|
|
|
function dhtget( username, resource, multi, cbFunc, cbArg ) { |
|
|
|
|
function dhtget( username, resource, multi, cbFunc, cbArg, timeoutArgs ) { |
|
|
|
|
var locator = _dhtgetLocator(username, resource, multi); |
|
|
|
|
if( locator in _dhtgetPendingMap) { |
|
|
|
|
_dhtgetAddPending(locator, cbFunc, cbArg); |
|
|
|
@ -98,7 +98,7 @@ function dhtget( username, resource, multi, cbFunc, cbArg ) {
@@ -98,7 +98,7 @@ function dhtget( username, resource, multi, cbFunc, cbArg ) {
|
|
|
|
|
// limit the number of simultaneous dhtgets.
|
|
|
|
|
// this should leave some sockets for other non-blocking daemon requests.
|
|
|
|
|
if( _dhtgetsInProgress < _maxDhtgets ) { |
|
|
|
|
_dhtgetInternal( username, resource, multi ); |
|
|
|
|
_dhtgetInternal( username, resource, multi, timeoutArgs ); |
|
|
|
|
} else { |
|
|
|
|
// just queue the locator. it will be unqueue when some dhtget completes.
|
|
|
|
|
_queuedDhtgets.push(locator); |
|
|
|
@ -106,10 +106,14 @@ function dhtget( username, resource, multi, cbFunc, cbArg ) {
@@ -106,10 +106,14 @@ function dhtget( username, resource, multi, cbFunc, cbArg ) {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function _dhtgetInternal( username, resource, multi ) { |
|
|
|
|
function _dhtgetInternal( username, resource, multi, timeoutArgs ) { |
|
|
|
|
var locator = _dhtgetLocator(username, resource, multi); |
|
|
|
|
_dhtgetsInProgress++; |
|
|
|
|
twisterRpc("dhtget", [username,resource,multi], |
|
|
|
|
argsList = [username,resource,multi]; |
|
|
|
|
if( typeof timeoutArgs !== 'undefined' ) { |
|
|
|
|
argsList = argsList.concat(timeoutArgs); |
|
|
|
|
} |
|
|
|
|
twisterRpc("dhtget", argsList, |
|
|
|
|
function(args, ret) { |
|
|
|
|
_dhtgetsInProgress--; |
|
|
|
|
_dhtgetProcessPending(args.locator, args.multi, ret); |
|
|
|
|