@@ -736,8 +736,16 @@ def smb_conn(c)
736
736
end
737
737
738
738
def smb_stop ( c )
739
+
739
740
# Make sure the socket is closed
740
- c . close rescue nil
741
+ begin
742
+ c . close
743
+ # Handle any number of errors that a double-close or failed shutdown can trigger
744
+ rescue ::IOError , ::EOFError ,
745
+ ::Errno ::ECONNRESET , ::Errno ::ENOTCONN , ::Errno ::ECONNABORTED ,
746
+ ::Errno ::ETIMEDOUT , ::Errno ::ENETRESET , ::Errno ::ESHUTDOWN
747
+ end
748
+
741
749
# Delete the state table entry
742
750
@state . delete ( c )
743
751
end
@@ -746,8 +754,16 @@ def smb_recv(c)
746
754
smb = @state [ c ]
747
755
smb [ :data ] ||= ''
748
756
749
- # Capture any low-level timeout exceptions to prevent it from bubbling
750
- buff = c . get_once ( -1 , 0.25 ) rescue nil
757
+ buff = ''
758
+ begin
759
+ buff = c . get_once ( -1 , 0.25 )
760
+ # Handle any number of errors that a read can trigger depending on socket state
761
+ rescue ::IOError , ::EOFError ,
762
+ ::Errno ::ECONNRESET , ::Errno ::ENOTCONN , ::Errno ::ECONNABORTED ,
763
+ ::Errno ::ETIMEDOUT , ::Errno ::ENETRESET , ::Errno ::ESHUTDOWN
764
+ smb_stop ( c )
765
+ return
766
+ end
751
767
752
768
# The client said it had data, but lied, kill the session
753
769
unless buff and buff . length > 0
0 commit comments