mirror of https://github.com/zlatinb/muwire
do not exit accept loop on I2PExceptions, GitHub issue #123
parent
9e8d6fe013
commit
75f65a61ca
|
@ -120,16 +120,7 @@ class ConnectionAcceptor {
|
||||||
private void acceptLoop() {
|
private void acceptLoop() {
|
||||||
try {
|
try {
|
||||||
while(true) {
|
while(true) {
|
||||||
def incoming
|
def incoming = acceptor.accept()
|
||||||
try {
|
|
||||||
incoming = acceptor.accept()
|
|
||||||
} catch (I2PException|ConnectException i2PException) {
|
|
||||||
if (shutdown)
|
|
||||||
throw i2PException
|
|
||||||
log.log(Level.WARNING, "I2P exception, maybe router disconnected?", i2PException)
|
|
||||||
Thread.sleep(10)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
log.info("accepted connection from ${incoming.destination.toBase32()}")
|
log.info("accepted connection from ${incoming.destination.toBase32()}")
|
||||||
switch(trustService.getLevel(incoming.destination)) {
|
switch(trustService.getLevel(incoming.destination)) {
|
||||||
case TrustLevel.TRUSTED : break
|
case TrustLevel.TRUSTED : break
|
||||||
|
|
|
@ -2,15 +2,19 @@ package com.muwire.core.connection
|
||||||
|
|
||||||
import com.muwire.core.RouterConnectedEvent
|
import com.muwire.core.RouterConnectedEvent
|
||||||
import com.muwire.core.RouterDisconnectedEvent
|
import com.muwire.core.RouterDisconnectedEvent
|
||||||
|
import groovy.util.logging.Log
|
||||||
|
import net.i2p.I2PException
|
||||||
import net.i2p.client.streaming.I2PServerSocket
|
import net.i2p.client.streaming.I2PServerSocket
|
||||||
import net.i2p.client.streaming.I2PSocketManager
|
import net.i2p.client.streaming.I2PSocketManager
|
||||||
|
|
||||||
import java.util.function.Supplier
|
import java.util.function.Supplier
|
||||||
|
import java.util.logging.Level
|
||||||
|
|
||||||
|
@Log
|
||||||
class I2PAcceptor {
|
class I2PAcceptor {
|
||||||
|
|
||||||
private final Supplier<I2PSocketManager> socketManager
|
private final Supplier<I2PSocketManager> socketManager
|
||||||
private I2PServerSocket serverSocket
|
private volatile I2PServerSocket serverSocket
|
||||||
|
|
||||||
I2PAcceptor() {}
|
I2PAcceptor() {}
|
||||||
|
|
||||||
|
@ -28,12 +32,19 @@ class I2PAcceptor {
|
||||||
}
|
}
|
||||||
|
|
||||||
Endpoint accept() {
|
Endpoint accept() {
|
||||||
I2PServerSocket serverSocket
|
while(true) {
|
||||||
synchronized (this) {
|
try {
|
||||||
while((serverSocket = this.serverSocket) == null)
|
I2PServerSocket serverSocket
|
||||||
wait()
|
synchronized (this) {
|
||||||
|
while((serverSocket = this.serverSocket) == null)
|
||||||
|
wait()
|
||||||
|
}
|
||||||
|
def socket = serverSocket.accept()
|
||||||
|
return new Endpoint(socket.getPeerDestination(), socket.getInputStream(), socket.getOutputStream(), socket)
|
||||||
|
} catch (I2PException|ConnectException routerDown) {
|
||||||
|
log.log(Level.WARNING, "router disconnected?", routerDown)
|
||||||
|
serverSocket = null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
def socket = serverSocket.accept()
|
|
||||||
new Endpoint(socket.getPeerDestination(), socket.getInputStream(), socket.getOutputStream(), socket)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue