comparison lib/Test/Nginx/SMTP.pm @ 1825:3629eda94c1b

Tests: handling of EWOULDBLOCK from sysread() with IO::Socket::SSL. With IO::Socket::SSL, when select() reports that the socket is readable, reading from it might still fail with EWOULDBLOCK, since no application data is available in the socket. In particular, this might happen with TLSv1.3 when a session ticket is received after the handshake. Fix is to explicitly check for EWOULDBLOCK errors.
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 21 Mar 2023 02:57:39 +0300
parents d0025a0dead7
children 7b7b64569f55
comparison
equal deleted inserted replaced
1824:5d3aee48ed8e 1825:3629eda94c1b
66 } 66 }
67 67
68 while (IO::Select->new($socket)->can_read(8)) { 68 while (IO::Select->new($socket)->can_read(8)) {
69 $socket->blocking(0); 69 $socket->blocking(0);
70 my $n = $socket->sysread(my $buf, 1024); 70 my $n = $socket->sysread(my $buf, 1024);
71 my $again = !defined $n && $!{EWOULDBLOCK};
71 $socket->blocking(1); 72 $socket->blocking(1);
73 next if $again;
72 last unless $n; 74 last unless $n;
73 75
74 $self->{_read_buffer} .= $buf; 76 $self->{_read_buffer} .= $buf;
75 77
76 if ($self->{_read_buffer} =~ /^(.*?\x0a)(.*)/ms) { 78 if ($self->{_read_buffer} =~ /^(.*?\x0a)(.*)/ms) {