File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -2189,10 +2189,25 @@ void FullCleanup()
21892189 /// Closes the socket and cleans up client-side resources associated with this connector.
21902190 /// </summary>
21912191 /// <remarks>
2192- /// This method doesn't actually perform any meaningful I/O, and therefore is sync-only.
2192+ /// This method doesn't actually perform any meaningful I/O (except sending TLS alert) , and therefore is sync-only.
21932193 /// </remarks>
21942194 void Cleanup( )
21952195 {
2196+ if ( _stream is SslStream sslStream )
2197+ {
2198+ try
2199+ {
2200+ // Send close_notify TLS alert to correctly close connection on postgres's side
2201+ sslStream. ShutdownAsync ( ) . GetAwaiter ( ) . GetResult ( ) ;
2202+ // Theoretically we should do a 0 read here to receive server's close_notify alert
2203+ // But overall it doesn't look like it makes much of a difference
2204+ }
2205+ catch
2206+ {
2207+ // ignored
2208+ }
2209+ }
2210+
21962211 try
21972212 {
21982213 _stream? . Dispose ( ) ;
You can’t perform that action at this time.
0 commit comments