Changeset c4ebc73
- Timestamp:
- Jun 2, 2019 11:08:38 AM (20 months ago)
- Branches:
- master
- Children:
- aa0bafb
- Parents:
- 471c5d4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
apps/i2ptunnel/java/src/net/i2p/i2ptunnel/TunnelControllerGroup.java
r471c5d4 rc4ebc73 77 77 /** 78 78 * In I2PAppContext will instantiate if necessary and always return non-null. 79 * As of 0.9.4, when in RouterContext, will return null (except in Android)79 * As of 0.9.4, when in RouterContext, will return null 80 80 * if the TCG has not yet been started by the router. 81 * As of 0.9.41, that's true for Android as well. 81 82 * 82 83 * @throws IllegalArgumentException if unable to load from i2ptunnel.config … … 85 86 synchronized (TunnelControllerGroup.class) { 86 87 if (_instance == null) { 87 I2PAppContext ctx = I2PAppContext.getGlobalContext(); 88 if (!SystemVersion.isAndroid()) { 89 I2PAppContext ctx = I2PAppContext.getGlobalContext(); 90 if (!ctx.isRouterContext()) { 91 _instance = new TunnelControllerGroup(ctx, null, null); 92 _instance.startup(); 93 } 94 } // else wait for the router to start it 95 } 96 return _instance; 97 } 98 } 99 100 /** 101 * In I2PAppContext will instantiate if necessary and always return non-null. 102 * When in RouterContext, will return null (except in Android) 103 * if the TCG has not yet been started by the router. 104 * In Android, if the old instance uses a stale context, it will replace it. 105 * 106 * @throws IllegalArgumentException if unable to load from i2ptunnel.config 107 * @since 0.9.41 108 */ 109 public static TunnelControllerGroup getInstance(I2PAppContext ctx) { 110 synchronized (TunnelControllerGroup.class) { 111 if (_instance == null) { 88 112 if (SystemVersion.isAndroid() || !ctx.isRouterContext()) { 89 113 _instance = new TunnelControllerGroup(ctx, null, null); 90 if (!SystemVersion.isAndroid()) 91 _instance.startup(); 114 _instance.startup(); 92 115 } // else wait for the router to start it 116 } else { 117 if (SystemVersion.isAndroid() && _instance._context != ctx) { 118 ctx.logManager().getLog(TunnelControllerGroup.class).warn("Old context in TCG"); 119 _instance.shutdown(); 120 _instance = new TunnelControllerGroup(ctx, null, null); 121 } 93 122 } 94 123 return _instance; … … 121 150 _sessions = new HashMap<I2PSession, Set<TunnelController>>(4); 122 151 synchronized (TunnelControllerGroup.class) { 123 if (_instance == null) 152 if (_instance == null) { 124 153 _instance = this; 125 }126 if (_instance != this) {127 _log.logAlways(Log.WARN, "New TunnelControllerGroup, now you have two");128 if (_log.shouldLog(Log.WARN))129 _log.warn("I did it", new Exception());154 } else { 155 _log.logAlways(Log.WARN, "New TunnelControllerGroup, now you have two"); 156 if (_log.shouldLog(Log.WARN)) 157 _log.warn("I did it", new Exception()); 158 } 130 159 } 131 160 _state = INITIALIZED;
Note: See TracChangeset
for help on using the changeset viewer.