mirror of
https://github.com/apple/swift-nio
synced 2026-11-30 05:28:44 +00:00
improve flushNow re-entrancy protection Motivation: The fix in #1344 wasn't complete, there is another, quite complicated scenario where we would still forget to send flushed bytes until we see another `flush` call. The scenario is 1: writable() 2: --> flushNow (result: .writtenCompletely) 3: --> writabilityChanged callout 4: --> flushNow because user calls writeAndFlush (result: .couldNotWriteEverything) 5: --> registerForWritable (because line 4 could not write everything and flushNow returned .register) 6: --> unregisterForWritable (because line 2 wrote everything and flushNow returned .unregister) Line 6 undoes the registeration in line 5. Modification: This fix makes sure that flushNow never re-enters and therefore the problem described above cannot happen anymore. Result: Hopefully actually fixes rdar://58571521