Author: robert
Date: 2007-12-03 23:45:38 +0000 (Mon, 03 Dec 2007)
New Revision: 16249
Modified:
trunk/freenet/src/freenet/node/PeerNode.java
trunk/freenet/src/freenet/node/RequestHandler.java
Log:
Fix synchronization target, remove redundant connection check.
Modified: trunk/freenet/src/freenet/node/PeerNode.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerNode.java 2007-12-03 23:17:43 UTC
(rev 16248)
+++ trunk/freenet/src/freenet/node/PeerNode.java 2007-12-03 23:45:38 UTC
(rev 16249)
@@ -872,8 +872,11 @@
public void sendAsync(Message msg, AsyncMessageCallback cb, int
alreadyReportedBytes, ByteCounter ctr) throws NotConnectedException {
if(logMINOR)
Logger.minor(this, "Sending async: " + msg + " : " + cb
+ " on " + this);
- if(!isConnected())
+ if(!isConnected()) {
+ if (cb instanceof SyncMessageCallback)
+ Logger.error(this, "Tried to send " + msg + " but not
connected to " + this, new Exception("debug"));
throw new NotConnectedException();
+ }
addToLocalNodeSentMessagesToStatistic(msg);
MessageItem item = new MessageItem(msg, cb == null ? null : new
AsyncMessageCallback[]{cb}, alreadyReportedBytes, ctr);
item.getData(this);
@@ -1255,15 +1258,9 @@
}
/**
- * Send a message, right now, on this thread, to this node.
+ * Enqueue a message to be sent to this node and wait up to a minute for
it to be transmitted.
*/
public void sendSync(Message req, ByteCounter ctr) throws
NotConnectedException {
- synchronized(this) {
- if(!isConnected()) {
- Logger.error(this, "Tried to send " + req + "
but not connected to " + this, new Exception("debug"));
- throw new NotConnectedException();
- }
- }
SyncMessageCallback cb = new SyncMessageCallback();
sendAsync(req, cb, 0, ctr);
cb.waitForSend(60 * 1000);
Modified: trunk/freenet/src/freenet/node/RequestHandler.java
===================================================================
--- trunk/freenet/src/freenet/node/RequestHandler.java 2007-12-03 23:17:43 UTC
(rev 16248)
+++ trunk/freenet/src/freenet/node/RequestHandler.java 2007-12-03 23:45:38 UTC
(rev 16249)
@@ -85,7 +85,7 @@
if((!finalTransferFailed) && rs != null && status !=
RequestSender.TIMED_OUT && status != RequestSender.GENERATED_REJECTED_OVERLOAD
&& status != RequestSender.INTERNAL_ERROR && !thrown) {
int sent, rcvd;
- synchronized(this) {
+ synchronized(bytesSync) {
sent = sentBytes;
rcvd = receivedBytes;
}