From 72782cea6c837cc02c03a234d104ccd30f92924b Mon Sep 17 00:00:00 2001 From: Miguel Freitas Date: Sat, 15 Feb 2014 17:34:55 -0200 Subject: [PATCH] use extended dhtget timeout parameters for mentions and hashtags (requires twister_core >= 0.9.14) --- twister_actions.js | 3 ++- twister_io.js | 12 ++++++++---- twister_newmsgs.js | 3 ++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/twister_actions.js b/twister_actions.js index 9053d1e..168f12e 100644 --- a/twister_actions.js +++ b/twister_actions.js @@ -194,7 +194,8 @@ function requestHashtag(postboard,hashtag,resource) { dhtget( hashtag, resource, "m", function(args, data) { processHashtag(args.postboard, args.hashtag, data); - }, {postboard:postboard,hashtag:hashtag} ); + }, {postboard:postboard,hashtag:hashtag}, + [10000,2000,3]); // use extended timeout parameters (requires twister_core >= 0.9.14) } diff --git a/twister_io.js b/twister_io.js index 8cb10db..7170ead 100644 --- a/twister_io.js +++ b/twister_io.js @@ -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 ) { // 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 ) { } } -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); diff --git a/twister_newmsgs.js b/twister_newmsgs.js index c5287e8..c1c1fad 100644 --- a/twister_newmsgs.js +++ b/twister_newmsgs.js @@ -69,7 +69,8 @@ function requestMentionsCount() { } $.MAL.updateNewMentionsUI(_newMentions); } - }, {}); + }, {}, + [10000,2000,3]); // use extended timeout parameters (requires twister_core >= 0.9.14) } function resetMentionsCount() {