AsyncSSLSocket getRawBytes fix
authorHeng Hong Lee <henghonglee@fb.com>
Tue, 23 Aug 2016 23:31:17 +0000 (16:31 -0700)
committerFacebook Github Bot <facebook-github-bot-bot@fb.com>
Tue, 23 Aug 2016 23:39:55 +0000 (16:39 -0700)
commit4d37864c657590b5460ee02eb68fd0b3b22237f7
tree89d90bfebd7a1e7aab941396db6c5f7636e6110c
parent0137d629ca981aac0186bf63bea82c2d5b9d7832
AsyncSSLSocket getRawBytes fix

Summary:
While adding logging around our socket and looking into `AsyncSSLSocket` it seems like the data that is actually written into the socket is not correctly attributed.  I
added logs and printed out what happens on the socket layer, P56563098 in this paste you can see that the `[fishhook]` logs are actually those added in D3698728.

Those are the actual bytes written onto the socket, in the paste, the bytes that are written by the AsyncSocket::bioWrite method are
the ones that actually get written onto the socket. some of the bytes written into the bio comes from bf_buff.c and bss_mem.c which are not eventually attributed to a
socket message and will be incorrectly counted when getRawBytesWritten/Read invoked on AsyncSSLSocket.cpp

Unfortunately/Fortunately this issue is not symmetrical and does not manifest in the getRawBytesReceived in AsyncSSLSocket, reading the bio for read bytes
correctly attributes the actual number of bytes written on the socket. moreover, pulling the asyncsocket data for getRawBytesRead doesnt give the full read bytes on
wire because SSL_connect and SSL_read dont return the number of bytes they read but return the number of bytes without the TLS bytes used.

siyengar seems like a right person to look at this. so adding him here.

Would love to discuss more about this and am open to iterating more on this solution

Reviewed By: knekritz

Differential Revision: D3698744

fbshipit-source-id: 541aa478778b9607f51db194fcbfe28bd23c737f
folly/io/async/AsyncSSLSocket.cpp