|
3 | 3 | // Macro |
4 | 4 | // |
5 | 5 | // Created by Helge Hess. |
6 | | -// Copyright © 2020-2022 ZeeZide GmbH. All rights reserved. |
| 6 | +// Copyright © 2020-2024 ZeeZide GmbH. All rights reserved. |
7 | 7 | // |
8 | 8 |
|
| 9 | +#if os(Linux) |
| 10 | + import let Glibc.ECONNRESET |
| 11 | +#else |
| 12 | + import let Darwin.ECONNRESET |
| 13 | +#endif |
9 | 14 | import class MacroCore.ErrorEmitter |
10 | 15 | import enum MacroCore.EventListenerSet |
11 | 16 | import class MacroCore.MacroCore |
12 | 17 | import struct MacroCore.Buffer |
13 | 18 | import struct Logging.Logger |
| 19 | +import struct NIOCore.IOError |
14 | 20 | import struct NIO.NIOAny |
15 | 21 | import class NIO.EventLoopFuture |
16 | 22 | import class NIO.ServerBootstrap |
@@ -538,12 +544,24 @@ open class Server: ErrorEmitter, CustomStringConvertible { |
538 | 544 | // HTTPParserError.invalidEOFState |
539 | 545 | server.log.error("HTTP error in TX \(id), closing connection: \(error)") |
540 | 546 | server.emitError(error, transaction: ( request, response )) |
| 547 | + self.transaction = nil |
541 | 548 | } |
542 | 549 | else { |
543 | | - server.log.error("HTTP error, closing connection: \(error)") |
| 550 | + assert(transaction == nil) |
| 551 | + var doError = true |
| 552 | + |
| 553 | + if let error = error as? IOError, error.errnoCode == ECONNRESET { |
| 554 | + doError = false |
| 555 | + } |
| 556 | + |
| 557 | + if doError { |
| 558 | + server.log.error("HTTP error, closing connection: \(error)") |
| 559 | + } |
| 560 | + else { |
| 561 | + server.log.trace("HTTP error, closing connection: \(error)") |
| 562 | + } |
544 | 563 | server.emitError(error, transaction: nil) |
545 | 564 | } |
546 | | - self.transaction = nil |
547 | 565 | context.close(promise: nil) |
548 | 566 | } |
549 | 567 | } |
|
0 commit comments