Use the number of subscribers to determine how many responses to expect.
Take the lock immediately if there are no subscribers. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4576 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -144,6 +144,14 @@ public class NodeObject extends DObject
|
|||||||
/** A field we use to broadcast changes to possible cached data. */
|
/** A field we use to broadcast changes to possible cached data. */
|
||||||
public CacheData cacheData;
|
public CacheData cacheData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of subscribers to this node.
|
||||||
|
*/
|
||||||
|
public int getSubscriberCount ()
|
||||||
|
{
|
||||||
|
return _scount;
|
||||||
|
}
|
||||||
|
|
||||||
// AUTO-GENERATED: METHODS START
|
// AUTO-GENERATED: METHODS START
|
||||||
/**
|
/**
|
||||||
* Requests that the <code>peerService</code> field be set to the
|
* Requests that the <code>peerService</code> field be set to the
|
||||||
|
|||||||
@@ -296,7 +296,12 @@ public class PeerManager
|
|||||||
queryLock(lock, new ResultListener<String>() {
|
queryLock(lock, new ResultListener<String>() {
|
||||||
public void requestCompleted (String result) {
|
public void requestCompleted (String result) {
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
_locks.put(lock, new LockHandler(lock, true, listener));
|
if (_nodeobj.getSubscriberCount() == 0) {
|
||||||
|
_nodeobj.addToLocks(lock);
|
||||||
|
listener.requestCompleted(_nodeName);
|
||||||
|
} else {
|
||||||
|
_locks.put(lock, new LockHandler(lock, true, listener));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
listener.requestCompleted(result);
|
listener.requestCompleted(result);
|
||||||
}
|
}
|
||||||
@@ -318,7 +323,12 @@ public class PeerManager
|
|||||||
queryLock(lock, new ResultListener<String>() {
|
queryLock(lock, new ResultListener<String>() {
|
||||||
public void requestCompleted (String result) {
|
public void requestCompleted (String result) {
|
||||||
if (_nodeName.equals(result)) {
|
if (_nodeName.equals(result)) {
|
||||||
_locks.put(lock, new LockHandler(lock, false, listener));
|
if (_nodeobj.getSubscriberCount() == 0) {
|
||||||
|
_nodeobj.removeFromLocks(lock);
|
||||||
|
listener.requestCompleted(null);
|
||||||
|
} else {
|
||||||
|
_locks.put(lock, new LockHandler(lock, false, listener));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
log.warning("Tried to release lock held by another peer [lock=" +
|
log.warning("Tried to release lock held by another peer [lock=" +
|
||||||
@@ -796,7 +806,7 @@ public class PeerManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
// find out exactly how many responses we need
|
// find out exactly how many responses we need
|
||||||
_remaining = _peers.size();
|
_remaining = _nodeobj.getSubscriberCount();
|
||||||
|
|
||||||
// schedule a timeout to act if something goes wrong
|
// schedule a timeout to act if something goes wrong
|
||||||
(_timeout = new Interval(PresentsServer.omgr) {
|
(_timeout = new Interval(PresentsServer.omgr) {
|
||||||
|
|||||||
Reference in New Issue
Block a user