Can read up to 5 bytes after every complete message
Opened this issue · 1 comments
Line 149 in d475251
The TLS chunks always start with a 5 byte header (1 byte content type, 2 bytes protocol version, 2 bytes length). At that point the length of the whole packet is known and SEC_E_INCOMPLETE_MESSAGE will be returned, usually providing the whole size in SECBUFFER_MISSING then (sometimes not, and byte by byte has to be read).
By starting with 5 bytes, performance should be improved a little bit.
I think this bug is outdated an can be closed. Currently in read_in()
at least 1024 bytes are allocated for the read even if needs_read = 1
.
Line 741 in 690a1aa
self.stream.read(buf)
will then happily read more than needs_read
bytes. The actual amount of bytes read nread
is then saturating_sub
tracted from needs_read
since we might have nread > needs_read
.
Line 750 in 690a1aa
And the loop continues to make sure that at least needs_read
bytes are read. In practice the first read(buf)
will often receive the whole message in one go or at least fill the initial 1024 bytes of the buffer.