• Brandon Schlinker's avatar
    Track rawBytesWritten · 8ea0a28b
    Brandon Schlinker authored
    Summary:
    During the wangle accept process and in a few pieces of application code we transform one type of `AsyncSocket` to another, potentially *after* a write has occurred.
    
    Since we do not currently carry `appBytesWritten` and `rawBytesWritten` during transformations, those values may not represent all bytes written. Likewise, if we transform from a `AsyncSSLSocket`, we lose count of the number of raw bytes written.
    
    It's very difficult to reason about whether these problems will actually manifest, so I'd prefer to just guard against it.
    
    With this change, we explicitly track the number of bytes written to the socket by incrementing a counter in `sendSocketMessage`, which is used by both `AsyncSocket` and `AsyncSSLSocket`. In addition, we copy the appBytesWritten and rawBytesWritten during socket moves.
    
    Reviewed By: yfeldblum
    
    Differential Revision: D24551958
    
    fbshipit-source-id: 88416114b52931ff3ceef847401d556ccf0ab664
    8ea0a28b
AsyncSocket.cpp 97.1 KB