* NTCP: Handle race where peer's NTCP address goes away

This commit is contained in:
zzz
2013-08-30 12:01:51 +00:00
parent de5f2940ce
commit 8655988c66

View File

@ -212,6 +212,7 @@ public class NTCPTransport extends TransportImpl {
Hash ih = ident.calculateHash();
NTCPConnection con = null;
boolean isNew = false;
boolean fail = false;
synchronized (_conLock) {
con = _conByIdent.get(ih);
if (con == null) {
@ -223,11 +224,19 @@ public class NTCPTransport extends TransportImpl {
_log.debug("Send on a new con: " + con + " at " + addr + " for " + ih);
_conByIdent.put(ih, con);
} else {
_log.error("we bid on a peer who doesn't have an ntcp address? " + target);
return;
// race, RI changed out from under us
// call afterSend below outside of conLock
fail = true;
}
}
}
if (fail) {
// race, RI changed out from under us, maybe SSU can handle it
if (_log.shouldLog(Log.WARN))
_log.warn("we bid on a peer who doesn't have an ntcp address? " + target);
afterSend(msg, false);
return;
}
if (isNew) {
con.enqueueInfoMessage(); // enqueues a netDb store of our own info
con.send(msg); // doesn't do anything yet, just enqueues it