Author: toad
Date: 2007-08-07 15:40:31 +0000 (Tue, 07 Aug 2007)
New Revision: 14508
Modified:
trunk/freenet/src/freenet/node/LocationManager.java
Log:
Synchronize on access to loc/locChangeSession within LocationManager (locks are
free if there's no contention, right?)
Modified: trunk/freenet/src/freenet/node/LocationManager.java
===================================================================
--- trunk/freenet/src/freenet/node/LocationManager.java 2007-08-07 15:38:20 UTC
(rev 14507)
+++ trunk/freenet/src/freenet/node/LocationManager.java 2007-08-07 15:40:31 UTC
(rev 14508)
@@ -87,7 +87,7 @@
this.loc = l;
}
- public void updateLocationChangeSession(double newLoc) {
+ public synchronized void updateLocationChangeSession(double newLoc) {
double oldLoc = loc;
// Patterned after PeerManager.distance( double, double ), but also
need to know the direction of the change
if (newLoc > oldLoc) {
@@ -158,7 +158,7 @@
if(System.currentTimeMillis() -
timeLastSuccessfullySwapped > 30*1000) {
try {
boolean myFlag = false;
- double myLoc = loc;
+ double myLoc = getLocation();
PeerNode[] peers = node.peers.connectedPeers;
for(int i=0;i<peers.length;i++) {
PeerNode pn = peers[i];
@@ -250,7 +250,7 @@
// Create my side
long random = r.nextLong();
- double myLoc = loc;
+ double myLoc = getLocation();
LocationUIDPair[] friendLocsAndUIDs =
node.peers.getPeerLocationsAndUIDs();
double[] friendLocs = extractLocs(friendLocsAndUIDs);
long[] myValueLong = new long[1+1+friendLocs.length];
@@ -380,7 +380,7 @@
// We can't lock friends_locations, so lets just
// pretend that they're locked
long random = r.nextLong();
- double myLoc = loc;
+ double myLoc = getLocation();
LocationUIDPair[] friendLocsAndUIDs =
node.peers.getPeerLocationsAndUIDs();
double[] friendLocs = extractLocs(friendLocsAndUIDs);
long[] myValueLong = new long[1+1+friendLocs.length];
@@ -546,7 +546,7 @@
* Tell all connected peers that our location has changed
*/
private void announceLocChange() {
- Message msg = DMT.createFNPLocChangeNotification(loc);
+ Message msg = DMT.createFNPLocChangeNotification(getLocation());
node.peers.localBroadcast(msg, false);
}