Skip to content

Commit 6291047

Browse files
committed
Merge branch 'main' into release
2 parents 6a68a8c + 9cb6d5a commit 6291047

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

Sources/ShapeshifterDispatcherSwift/AsyncRoutingController.swift

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class AsyncRoutingController
1919
{
2020
while true
2121
{
22-
appLog.debug("Async router listening for connections...")
22+
appLog.debug("Listening for connections...")
2323

2424
do
2525
{
@@ -32,7 +32,7 @@ class AsyncRoutingController
3232
let transportConnection = try AsyncAwaitThrowingSynchronizer<AsyncConnection>.sync
3333
{
3434
let connection = try await listener.accept()
35-
appLog.debug("Accepted a transport connection.")
35+
appLog.debug("ShapeshifterDispatcher.handleListener: Accepted a transport connection.")
3636
return connection
3737
}
3838

@@ -41,30 +41,37 @@ class AsyncRoutingController
4141
do
4242
{
4343
let targetConnection = try await AsyncTcpSocketConnection(targetHost, targetPort, appLog)
44-
appLog.debug("A target connection was created.")
44+
appLog.debug("ShapeshifterDispatcher.handleListener: Created a connection to the target host.")
4545
let route = AsyncRouter(controller: self, transportConnection: transportConnection, targetConnection: targetConnection)
46-
appLog.debug("ShapeshifterDispatcherSwift: new route created.")
46+
appLog.debug("ShapeshifterDispatcher.handleListener: Created a new route.")
4747
routes.append(route)
4848
}
4949
catch (let targetConnectionError)
5050
{
51-
appLog.error("Failed to connect to the application server. Error: \(targetConnectionError)")
52-
try await listener.close()
53-
return
51+
appLog.warning("ShapeshifterDispatcher.handleListener: A client connection could not be accepted, we failed to connect to the application server. Reason: \(targetConnectionError)")
5452
}
5553
}
5654
}
5755
catch AsyncDarkstarServerError.blackHoled
5856
{
59-
appLog.error("ShapeshifterDispatcher.handleListener: Failed to accept a new connection: blackHoled")
57+
appLog.warning("ShapeshifterDispatcher.handleListener: Failed to accept a new connection: blackHoled")
6058
continue
6159
}
62-
catch
60+
catch AsyncTcpSocketListenerError.socketError
6361
{
64-
appLog.error("ShapeshifterDispatcher.handleListener: Failed to accept a new connection: \(error)")
62+
appLog.error("Received a socket error while trying to accept a connection. This is a fatal error. Exiting...")
63+
Task
64+
{
65+
try await listener.close()
66+
}
67+
6568
return
6669
}
67-
70+
catch
71+
{
72+
appLog.warning("ShapeshifterDispatcher.handleListener: Failed to accept a new connection: \(error)")
73+
continue
74+
}
6875
}
6976
}
7077

0 commit comments

Comments
 (0)