Changeset 4322cb3
- Timestamp:
- Dec 17, 2011 6:52:23 PM (9 years ago)
- Branches:
- master
- Children:
- a2454e8e
- Parents:
- a7311a57 (diff), b18e7c7 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
apps/i2psnark/java/src/org/klomp/snark/Storage.java
ra7311a57 r4322cb3 24 24 import java.io.IOException; 25 25 import java.io.RandomAccessFile; 26 import java.nio.charset.Charset; 27 import java.nio.charset.CharsetEncoder; 26 28 import java.security.MessageDigest; 27 29 import java.util.ArrayList; 28 30 import java.util.Iterator; 29 31 import java.util.List; 32 import java.util.Map; 30 33 import java.util.StringTokenizer; 34 import java.util.concurrent.ConcurrentHashMap; 31 35 32 36 import net.i2p.crypto.SHA1; … … 67 71 public static final int MAX_PIECES = 10*1024; 68 72 public static final long MAX_TOTAL_SIZE = MAX_PIECE_SIZE * (long) MAX_PIECES; 73 74 private static final Map<String, String> _filterNameCache = new ConcurrentHashMap(); 69 75 70 76 /** … … 569 575 * Removes 'suspicious' characters from the given file name. 570 576 * http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29.aspx 577 * Then replace chars not supported in the charset. 578 * 579 * This is called frequently and it can be pretty slow so cache the result. 580 * 581 * TODO: If multiple files in the same torrent map to the same filter name, 582 * the whole torrent will blow up. Check at torrent creation? 571 583 */ 572 584 public static String filterName(String name) 573 585 { 574 if (name.equals(".") || name.equals(" ")) 575 return "_"; 576 String rv = name; 577 if (rv.startsWith(".")) 578 rv = '_' + rv.substring(1); 579 if (rv.endsWith(".") || rv.endsWith(" ")) 580 rv = rv.substring(0, rv.length() - 1) + '_'; 581 for (int i = 0; i < ILLEGAL.length; i++) { 582 if (rv.indexOf(ILLEGAL[i]) >= 0) 583 rv = rv.replace(ILLEGAL[i], '_'); 584 } 586 String rv = _filterNameCache.get(name); 587 if (rv != null) 588 return rv; 589 if (name.equals(".") || name.equals(" ")) { 590 rv = "_"; 591 } else { 592 rv = name; 593 if (rv.startsWith(".")) 594 rv = '_' + rv.substring(1); 595 if (rv.endsWith(".") || rv.endsWith(" ")) 596 rv = rv.substring(0, rv.length() - 1) + '_'; 597 for (int i = 0; i < ILLEGAL.length; i++) { 598 if (rv.indexOf(ILLEGAL[i]) >= 0) 599 rv = rv.replace(ILLEGAL[i], '_'); 600 } 601 // Replace characters not supported in the charset 602 if (!Charset.defaultCharset().name().equals("UTF-8")) { 603 try { 604 CharsetEncoder enc = Charset.defaultCharset().newEncoder(); 605 if (!enc.canEncode(rv)) { 606 String repl = rv; 607 for (int i = 0; i < rv.length(); i++) { 608 char c = rv.charAt(i); 609 if (!enc.canEncode(c)) 610 repl = repl.replace(c, '_'); 611 } 612 rv = repl; 613 } 614 } catch (Exception ex) { 615 ex.printStackTrace(); 616 } 617 } } 618 _filterNameCache.put(name, rv); 585 619 return rv; 586 620 } -
apps/i2psnark/java/src/org/klomp/snark/web/I2PSnarkServlet.java
ra7311a57 r4322cb3 1760 1760 //buf.append("<br>").append(_("Maggot link")).append(": <a href=\"").append(MAGGOT).append(hex).append(':').append(hex).append("\">") 1761 1761 // .append(MAGGOT).append(hex).append(':').append(hex).append("</a>"); 1762 buf.append("<br>").append(_("Torrent file")).append(": ").append(snark.getName()); 1762 1763 buf.append("</div></th></tr>"); 1763 1764 } -
build.xml
ra7311a57 r4322cb3 889 889 </exec> 890 890 <exec executable="echo" osfamily="unix" failifexecutionfails="true" output="pkg-temp/history.txt" append="true"> 891 <arg value=" EARLIER HISTORY IS AVAILABLE IN THE SOURCE PACKAGE" />891 <arg value=" ---------------- EARLIER HISTORY IS AVAILABLE IN THE SOURCE PACKAGE" /> 892 892 </exec> 893 893 <copy file="installer/resources/deletelist.txt" todir="pkg-temp/" /> -
core/java/src/net/i2p/util/SimpleTimer2.java
ra7311a57 r4322cb3 236 236 _log.warn(_pool + " wtf, early execution " + delay + ": " + this); 237 237 else if (_log.shouldLog(Log.WARN) && delay < -1000) 238 _log.warn(" wtf, late execution " + delay+ ": " + this + _pool.debug());238 _log.warn(" wtf, late execution " + (0 - delay) + ": " + this + _pool.debug()); 239 239 try { 240 240 timeReached(); -
history.txt
ra7311a57 r4322cb3 1 2011-12-17 zzz 2 * i2psnark: 3 - Replace file name characters not supported in default charset 4 - Add torrent file name to local details page 5 * GeoIP: Reduce thread priority during lookup 6 * ProfileManager: Make some methods non-blocking to reduce 7 lock contention in transports 8 1 9 2011-12-15 kytv 2 10 * Swedish translation updates from Transifex -
router/java/src/net/i2p/router/InNetMessagePool.java
ra7311a57 r4322cb3 147 147 // level = Log.INFO; 148 148 if (_log.shouldLog(level)) 149 _log.log(level, "D uplicate message received[" + messageBody.getUniqueId()150 + " expiring on " + exp + "]: " + messageBody.getClass().get Name() + ": " + invalidReason149 _log.log(level, "Dropping message [" + messageBody.getUniqueId() 150 + " expiring on " + exp + "]: " + messageBody.getClass().getSimpleName() + ": " + invalidReason 151 151 + ": " + messageBody); 152 152 _context.statManager().addRateData("inNetPool.dropped", 1, 0); 153 // FIXME not necessarily a duplicate, could be expired too long ago / too far in future 153 154 _context.statManager().addRateData("inNetPool.duplicate", 1, 0); 154 155 _context.messageHistory().droppedOtherMessage(messageBody, (fromRouter != null ? fromRouter.calculateHash() : fromRouterHash)); 155 156 _context.messageHistory().messageProcessingError(messageBody.getUniqueId(), 156 messageBody.getClass().get Name(),157 messageBody.getClass().getSimpleName(), 157 158 "Duplicate/expired"); 158 159 return -1; -
router/java/src/net/i2p/router/RouterVersion.java
ra7311a57 r4322cb3 19 19 public final static String ID = "Monotone"; 20 20 public final static String VERSION = CoreVersion.VERSION; 21 public final static long BUILD = 2 1;21 public final static long BUILD = 22; 22 22 23 23 /** for example "-test" */ 24 public final static String EXTRA = " ";24 public final static String EXTRA = "-rc"; 25 25 public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA; 26 26 public static void main(String args[]) { -
router/java/src/net/i2p/router/message/GarlicMessageReceiver.java
ra7311a57 r4322cb3 113 113 + " expiration " + howLongAgo + " ago: " + invalidReason + ": " + clove); 114 114 _context.messageHistory().messageProcessingError(clove.getCloveId(), 115 clove.getData().getClass().get Name(),115 clove.getData().getClass().getSimpleName(), 116 116 "Clove is not valid (expiration " + howLongAgo + " ago)"); 117 117 } -
router/java/src/net/i2p/router/peermanager/ProfileManagerImpl.java
ra7311a57 r4322cb3 22 22 import net.i2p.util.Log; 23 23 24 /** 25 * Methods to update profiles. 26 * Unless otherwise noted, methods are blocking on the reorganize lock. 27 */ 24 28 public class ProfileManagerImpl implements ProfileManager { 25 29 private final Log _log; … … 34 38 * Note that it took msToSend to send a message of size bytesSent to the peer over the transport. 35 39 * This should only be called if the transport considered the send successful. 36 * 40 * Non-blocking. Will not update the profile if we can't get the lock. 37 41 */ 38 42 public void messageSent(Hash peer, String transport, long msToSend, long bytesSent) { 39 PeerProfile data = getProfile (peer);43 PeerProfile data = getProfileNonblocking(peer); 40 44 if (data == null) return; 41 45 data.setLastSendSuccessful(_context.clock().now()); … … 44 48 45 49 /** 46 * Note that the router failed to send a message to the peer over the transport specified 47 * 50 * Note that the router failed to send a message to the peer over the transport specified. 51 * Non-blocking. Will not update the profile if we can't get the lock. 48 52 */ 49 53 public void messageFailed(Hash peer, String transport) { 50 PeerProfile data = getProfile (peer);54 PeerProfile data = getProfileNonblocking(peer); 51 55 if (data == null) return; 52 56 data.setLastSendFailed(_context.clock().now()); … … 54 58 55 59 /** 56 * Note that the router failed to send a message to the peer over any transport 57 * 60 * Note that the router failed to send a message to the peer over any transport. 61 * Non-blocking. Will not update the profile if we can't get the lock. 58 62 */ 59 63 public void messageFailed(Hash peer) { 60 PeerProfile data = getProfile (peer);64 PeerProfile data = getProfileNonblocking(peer); 61 65 if (data == null) return; 62 66 data.setLastSendFailed(_context.clock().now()); … … 71 75 _log.info("Comm error occurred for peer " + peer.toBase64(), new Exception("Comm error")); 72 76 PeerProfile data = getProfile(peer); 73 if (data == null) return;77 //if (data == null) return; 74 78 data.setLastSendFailed(_context.clock().now()); 75 79 } … … 81 85 public void tunnelJoined(Hash peer, long responseTimeMs) { 82 86 PeerProfile data = getProfile(peer); 83 if (data == null) return;87 //if (data == null) return; 84 88 data.getTunnelCreateResponseTime().addData(responseTimeMs, responseTimeMs); 85 89 data.setLastHeardFrom(_context.clock().now()); … … 96 100 public void tunnelRejected(Hash peer, long responseTimeMs, int severity) { 97 101 PeerProfile data = getProfile(peer); 98 if (data == null) return;102 //if (data == null) return; 99 103 data.setLastHeardFrom(_context.clock().now()); 100 104 data.getTunnelHistory().incrementRejected(severity); … … 109 113 public void tunnelTimedOut(Hash peer) { 110 114 PeerProfile data = getProfile(peer); 111 if (data == null) return;115 //if (data == null) return; 112 116 data.getTunnelHistory().incrementRejected(TunnelHistory.TUNNEL_REJECT_BANDWIDTH); 113 117 } … … 120 124 public void tunnelTestSucceeded(Hash peer, long responseTimeMs) { 121 125 PeerProfile data = getProfile(peer); 122 if (data == null) return;126 //if (data == null) return; 123 127 data.updateTunnelTestTimeAverage(responseTimeMs); 124 128 data.getTunnelTestResponseTime().addData(responseTimeMs, responseTimeMs); … … 129 133 return; 130 134 PeerProfile data = getProfile(peer); 131 if (data != null)135 //if (data != null) 132 136 data.dataPushed(size); // ignore rtt, as we are averaging over a minute 133 137 } 138 134 139 public void tunnelDataPushed1m(Hash peer, int size) { 135 140 if (_context.routerHash().equals(peer)) 136 141 return; 137 142 PeerProfile data = getProfile(peer); 138 if (data != null)143 //if (data != null) 139 144 data.dataPushed1m(size); 140 145 } … … 145 150 return; 146 151 PeerProfile data = getProfile(peer); 147 if (data != null)152 //if (data != null) 148 153 data.tunnelDataTransferred(size); 149 154 } … … 163 168 public void tunnelFailed(Hash peer, int pct) { 164 169 PeerProfile data = getProfile(peer); 165 if (data == null) return;170 //if (data == null) return; 166 171 data.setLastHeardFrom(_context.clock().now()); 167 172 data.getTunnelHistory().incrementFailed(pct); … … 175 180 public void dbLookupSuccessful(Hash peer, long responseTimeMs) { 176 181 PeerProfile data = getProfile(peer); 177 if (data == null) return;182 //if (data == null) return; 178 183 data.setLastHeardFrom(_context.clock().now()); 179 184 if (!data.getIsExpandedDB()) … … 192 197 public void dbLookupFailed(Hash peer) { 193 198 PeerProfile data = getProfile(peer); 194 if (data == null) return;199 //if (data == null) return; 195 200 if (!data.getIsExpandedDB()) 196 201 data.expandDBProfile(); … … 209 214 public void dbLookupReply(Hash peer, int newPeers, int oldPeers, int invalid, int duplicate, long responseTimeMs) { 210 215 PeerProfile data = getProfile(peer); 211 if (data == null) return;216 //if (data == null) return; 212 217 data.setLastHeardFrom(_context.clock().now()); 213 218 if (!data.getIsExpandedDB()) … … 225 230 public void dbLookupReceived(Hash peer) { 226 231 PeerProfile data = getProfile(peer); 227 if (data == null) return;232 //if (data == null) return; 228 233 data.setLastHeardFrom(_context.clock().now()); 229 234 if (!data.getIsExpandedDB()) … … 239 244 public void dbStoreReceived(Hash peer, boolean wasNewKey) { 240 245 PeerProfile data = getProfile(peer); 241 if (data == null) return;246 //if (data == null) return; 242 247 data.setLastHeardFrom(_context.clock().now()); 243 248 if (!data.getIsExpandedDB()) … … 258 263 public void dbStoreSent(Hash peer, long responseTimeMs) { 259 264 PeerProfile data = getProfile(peer); 260 if (data == null) return;265 //if (data == null) return; 261 266 long now = _context.clock().now(); 262 267 data.setLastHeardFrom(now); … … 276 281 public void dbStoreSuccessful(Hash peer) { 277 282 PeerProfile data = getProfile(peer); 278 if (data == null) return;283 //if (data == null) return; 279 284 long now = _context.clock().now(); 280 285 data.setLastHeardFrom(now); … … 294 299 public void dbStoreFailed(Hash peer) { 295 300 PeerProfile data = getProfile(peer); 296 if (data == null) return;301 //if (data == null) return; 297 302 if (!data.getIsExpandedDB()) 298 303 data.expandDBProfile(); … … 309 314 public void heardAbout(Hash peer) { 310 315 PeerProfile data = getProfile(peer); 311 if (data == null) return;316 //if (data == null) return; 312 317 data.setLastHeardAbout(_context.clock().now()); 313 318 } … … 319 324 public void heardAbout(Hash peer, long when) { 320 325 PeerProfile data = getProfile(peer); 321 if (data == null) return;326 //if (data == null) return; 322 327 if (when > data.getLastHeardAbout()) 323 328 data.setLastHeardAbout(when); … … 328 333 * transport. Messages received without any "from" information aren't recorded 329 334 * through this metric. If msToReceive is negative, there was no timing information 330 * available 331 * 335 * available. 336 * Non-blocking. Will not update the profile if we can't get the lock. 332 337 */ 333 338 public void messageReceived(Hash peer, String style, long msToReceive, int bytesRead) { 334 PeerProfile data = getProfile (peer);339 PeerProfile data = getProfileNonblocking(peer); 335 340 if (data == null) return; 336 341 data.setLastHeardFrom(_context.clock().now()); … … 338 343 } 339 344 345 /** 346 * Blocking. 347 * Creates a new profile if it didn't exist. 348 * @return non-null 349 */ 340 350 private PeerProfile getProfile(Hash peer) { 341 351 PeerProfile prof = _context.profileOrganizer().getProfile(peer); … … 348 358 } 349 359 350 351 /** provide a simple summary of a number of peers, suitable for publication in the netDb */ 360 /** 361 * Non-blocking. 362 * @return null if the profile doesn't exist, or the fetch would have blocked 363 * @since 0.8.12 364 */ 365 private PeerProfile getProfileNonblocking(Hash peer) { 366 return _context.profileOrganizer().getProfileNonblocking(peer); 367 } 368 369 /** 370 * provide a simple summary of a number of peers, suitable for publication in the netDb 371 * @deprecated unused 372 */ 352 373 public Properties summarizePeers(int numPeers) { 374 /**** 353 375 Set peers = new HashSet(numPeers); 354 376 // lets get the fastest ones we've got (this fails over to include just plain reliable, 355 377 // or even notFailing peers if there aren't enough fast ones) 356 378 _context.profileOrganizer().selectFastPeers(numPeers, null, peers); 379 ****/ 357 380 Properties props = new Properties(); 381 /**** 358 382 for (Iterator iter = peers.iterator(); iter.hasNext(); ) { 359 383 Hash peer = (Hash)iter.next(); … … 385 409 props.setProperty("profile." + peer.toBase64().replace('=', '_'), buf.toString()); 386 410 } 411 ****/ 387 412 return props; 388 413 } 389 414 415 /**** 390 416 private final static DecimalFormat _fmt = new DecimalFormat("##0.00", new DecimalFormatSymbols(Locale.UK)); 391 417 private final static String num(double val) { 392 418 synchronized (_fmt) { return _fmt.format(val); } 393 419 } 420 ****/ 394 421 } -
router/java/src/net/i2p/router/peermanager/ProfileOrganizer.java
ra7311a57 r4322cb3 53 53 /** H(routerIdnetity), containing elements in _notFailingPeers */ 54 54 private final List<Hash> _notFailingPeersList; 55 /** H(routerIdentity) to PeerProfile for all peers that ARE failing horribly (but that we haven't dropped reference to yet) */55 /** TO BE REMOVED H(routerIdentity) to PeerProfile for all peers that ARE failing horribly (but that we haven't dropped reference to yet) */ 56 56 private final Map<Hash, PeerProfile> _failingPeers; 57 57 /** who are we? */ … … 121 121 } 122 122 123 /** 124 * Get the lock if we can. Non-blocking. 125 * @return true if the lock was acquired 126 * @since 0.8.12 127 */ 128 private boolean tryReadLock() { 129 return _reorganizeLock.readLock().tryLock(); 130 } 131 123 132 private void releaseReadLock() { 124 133 _reorganizeLock.readLock().unlock(); … … 148 157 149 158 /** 150 * Retrieve the profile for the given peer, if one exists (else null) 151 * 159 * Retrieve the profile for the given peer, if one exists (else null). 160 * Blocking if a reorganize is happening. 152 161 */ 153 162 public PeerProfile getProfile(Hash peer) { … … 156 165 return locked_getProfile(peer); 157 166 } finally { releaseReadLock(); } 167 } 168 169 /** 170 * Retrieve the profile for the given peer, if one exists (else null). 171 * Non-blocking. Returns null if a reorganize is happening. 172 * @since 0.8.12 173 */ 174 public PeerProfile getProfileNonblocking(Hash peer) { 175 if (tryReadLock()) { 176 try { 177 return locked_getProfile(peer); 178 } finally { releaseReadLock(); } 179 } 180 return null; 158 181 } 159 182 … … 244 267 public boolean isHighCapacity(Hash peer) { return isX(_highCapacityPeers, peer); } 245 268 public boolean isWellIntegrated(Hash peer) { return isX(_wellIntegratedPeers, peer); } 246 public boolean isFailing(Hash peer) { return isX(_failingPeers, peer); } 269 270 /** 271 * Deprecated for now, always false 272 */ 273 public boolean isFailing(Hash peer) { 274 // Always false so skip the lock 275 //return isX(_failingPeers, peer); 276 return false; 277 } 247 278 248 279 /** @since 0.8.8 */ -
router/java/src/net/i2p/router/transport/GeoIP.java
ra7311a57 r4322cb3 99 99 return; 100 100 } 101 LookupJob j = new LookupJob(); 102 j.run(); 103 updateOurCountry(); 101 int pri = Thread.currentThread().getPriority(); 102 if (pri > Thread.MIN_PRIORITY) 103 Thread.currentThread().setPriority(pri - 1); 104 try { 105 LookupJob j = new LookupJob(); 106 j.run(); 107 updateOurCountry(); 108 } finally { 109 if (pri > Thread.MIN_PRIORITY) 110 Thread.currentThread().setPriority(pri); 111 } 104 112 } 105 113 -
router/java/src/net/i2p/router/transport/udp/IntroductionManager.java
ra7311a57 r4322cb3 127 127 continue; 128 128 } 129 if ( _context.profileOrganizer().isFailing(cur.getRemotePeer()) ||129 if ( /* _context.profileOrganizer().isFailing(cur.getRemotePeer()) || */ 130 130 _context.shitlist().isShitlisted(cur.getRemotePeer()) || 131 131 _transport.wasUnreachable(cur.getRemotePeer())) { -
router/java/src/net/i2p/router/tunnel/HopProcessor.java
ra7311a57 r4322cb3 13 13 * inbound and outbound participants, outbound endpoints, 14 14 * and inbound gateways (with a small modification per 15 * Inb uondGatewayProcessor).15 * InboundGatewayProcessor). 16 16 * 17 17 */ … … 78 78 if (!okIV) { 79 79 if (_log.shouldLog(Log.WARN)) 80 _log.warn("Invalid IV received on tunnel " + _config.getReceiveTunnel());80 _log.warn("Invalid IV, dropping at hop " + _config); 81 81 return false; 82 82 } … … 112 112 _context.aes().encryptBlock(orig, offset, _config.getIVKey(), orig, offset); 113 113 } 114 115 /** 116 * @since 0.8.12 117 */ 118 @Override 119 public String toString() { 120 return getClass().getSimpleName() + " for " + _config; 121 } 114 122 } -
router/java/src/net/i2p/router/tunnel/InboundEndpointProcessor.java
ra7311a57 r4322cb3 64 64 if (!ok) { 65 65 if (_log.shouldLog(Log.WARN)) 66 _log.warn("Invalid IV received");66 _log.warn("Invalid IV, dropping at IBEP " + _config); 67 67 _cache.release(ba); 68 68 return false; -
router/java/src/net/i2p/router/tunnel/pool/TunnelPool.java
ra7311a57 r4322cb3 81 81 _inProgress.clear(); 82 82 } 83 if (_log.shouldLog(Log. WARN))84 _log. warn(toString() + ": Startup() called, was already alive? " + _alive, new Exception());83 if (_log.shouldLog(Log.INFO)) 84 _log.info(toString() + ": Startup() called, was already alive? " + _alive, new Exception()); 85 85 _alive = true; 86 86 _started = System.currentTimeMillis();
Note: See TracChangeset
for help on using the changeset viewer.