Skip to content

Commit 6d419a0

Browse files
committed
Fixed streamInUse not reset on exception
The streamInUse latch was not being reset when an exception was encountered writing to the stream. This is now handled in a try-catch-finally block.
1 parent 0402380 commit 6d419a0

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

WinNUT_V2/WinNUT-Client_Common/Nut_Socket.vb

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,16 @@ Public Class Nut_Socket
203203
If ConnectionStatus Then
204204
streamInUse = True
205205

206-
WriterStream.WriteLine(Query_Msg & vbCr)
207-
WriterStream.Flush()
208-
DataResult = Trim(ReaderStream.ReadLine())
209-
210-
streamInUse = False
206+
Try
207+
WriterStream.WriteLine(Query_Msg & vbCr)
208+
WriterStream.Flush()
209+
Catch
210+
Throw
211+
Finally
212+
streamInUse = False
213+
End Try
211214

215+
DataResult = Trim(ReaderStream.ReadLine())
212216
Response = EnumResponse(DataResult)
213217
finalTransaction = New Transaction(Query_Msg, DataResult, Response)
214218

0 commit comments

Comments
 (0)