View Issue Details

IDProjectCategoryView StatusLast Update
0036443FPCPatchpublic2019-12-15 18:14
ReporterAndrewHAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.3.1Product Build 
Target VersionFixed in Version3.3.1 
Summary0036443: [PATCH] TOpenSSLSocketHandler.Recv blocks forever even when IOTimeout is set
DescriptionHi,

This patch allows TOpenSSLSocketHandler.Recv to obey the IOTimeout of the socket it is attached to. Otherwise Socket.Read(x) blocks until data is received.
TagsNo tags attached.
Fixed in Revision43693
FPCOldBugId
FPCTarget3.2.0
Attached Files
  • ssl_block_read.diff (537 bytes)
    diff --git a/packages/openssl/src/opensslsockets.pp b/packages/openssl/src/opensslsockets.pp
    index 88870a22c5..1484c05dd0 100644
    --- a/packages/openssl/src/opensslsockets.pp
    +++ b/packages/openssl/src/opensslsockets.pp
    @@ -298,6 +298,8 @@ begin
       repeat
         Result:=FSSL.Read(@Buffer ,Count);
         e:=FSSL.GetError(Result);
    +    if (e=SSL_ERROR_WANT_READ) and (Socket.IOTimeout>0) then
    +      e:=SSL_ERROR_ZERO_RETURN;
       until Not (e in [SSL_ERROR_WANT_READ,SSL_ERROR_WANT_WRITE]);
       if (E=SSL_ERROR_ZERO_RETURN) then
         Result:=0
    
    ssl_block_read.diff (537 bytes)

Activities

AndrewH

2019-12-15 17:46

developer  

ssl_block_read.diff (537 bytes)
diff --git a/packages/openssl/src/opensslsockets.pp b/packages/openssl/src/opensslsockets.pp
index 88870a22c5..1484c05dd0 100644
--- a/packages/openssl/src/opensslsockets.pp
+++ b/packages/openssl/src/opensslsockets.pp
@@ -298,6 +298,8 @@ begin
   repeat
     Result:=FSSL.Read(@Buffer ,Count);
     e:=FSSL.GetError(Result);
+    if (e=SSL_ERROR_WANT_READ) and (Socket.IOTimeout>0) then
+      e:=SSL_ERROR_ZERO_RETURN;
   until Not (e in [SSL_ERROR_WANT_READ,SSL_ERROR_WANT_WRITE]);
   if (E=SSL_ERROR_ZERO_RETURN) then
     Result:=0
ssl_block_read.diff (537 bytes)

Michael Van Canneyt

2019-12-15 18:14

administrator   ~0119855

Checked & applied patch. Thank you !

Issue History

Date Modified Username Field Change
2019-12-15 17:40 AndrewH New Issue
2019-12-15 17:40 AndrewH File Added: ssl_block_read.diff
2019-12-15 17:44 AndrewH Assigned To => AndrewH
2019-12-15 17:44 AndrewH Status new => assigned
2019-12-15 17:44 AndrewH Assigned To AndrewH =>
2019-12-15 17:45 AndrewH Status assigned => new
2019-12-15 17:45 AndrewH Description Updated View Revisions
2019-12-15 17:45 AndrewH FPCTarget => -
2019-12-15 17:46 AndrewH File Deleted: ssl_block_read.diff
2019-12-15 17:46 AndrewH File Added: ssl_block_read.diff
2019-12-15 18:10 Michael Van Canneyt Assigned To => Michael Van Canneyt
2019-12-15 18:10 Michael Van Canneyt Status new => assigned
2019-12-15 18:14 Michael Van Canneyt Status assigned => resolved
2019-12-15 18:14 Michael Van Canneyt Resolution open => fixed
2019-12-15 18:14 Michael Van Canneyt Fixed in Version => 3.3.1
2019-12-15 18:14 Michael Van Canneyt Fixed in Revision => 43693
2019-12-15 18:14 Michael Van Canneyt FPCTarget - => 3.2.0
2019-12-15 18:14 Michael Van Canneyt Note Added: 0119855