@@ -612,7 +612,6 @@ def sendall(self, data, flags=0):
612612
613613 while sent < length :
614614 ret = self .write (data [sent :])
615-
616615 sent += ret
617616
618617 return None
@@ -736,7 +735,8 @@ def unwrap(self):
736735 Returns the wrapped OS socket.
737736 """
738737 if self .native_object != _ffi .NULL :
739- _lib .wolfSSL_shutdown (self .native_object )
738+ if self ._connected :
739+ _lib .wolfSSL_shutdown (self .native_object )
740740 self ._release_native_object ()
741741
742742 sock = socket (family = self ._sock .family ,
@@ -750,7 +750,7 @@ def unwrap(self):
750750 return sock
751751
752752 def add_peer (self , addr ):
753- peerAddr = _lib .wolfSSL_dtls_create_peer (addr [1 ],t2b (addr [0 ]))
753+ peerAddr = _lib .wolfSSL_dtls_create_peer (addr [1 ], t2b (addr [0 ]))
754754 if peerAddr == _ffi .NULL :
755755 raise SSLError ("Failed to create peer" )
756756 try :
@@ -912,7 +912,8 @@ def version(self):
912912 # API and are provided here for compatibility.
913913 def close (self ):
914914 if self .native_object != _ffi .NULL :
915- _lib .wolfSSL_shutdown (self .native_object )
915+ if self ._connected :
916+ _lib .wolfSSL_shutdown (self .native_object )
916917 self ._release_native_object ()
917918 self ._sock .close ()
918919
0 commit comments