Skip to content

TCP read/write incorrectly adjusts bytes to read/write on errors #27

@anderspkd

Description

@anderspkd

Both the send and receive handling in the TCP code (in net/tcp_channel.h) goes something like:

while (rem > 0) {
  // attempt to read/write using a sys call. The result is a ssize_t type that is stored in a variable res.
  if (res < 0) {
    // do error handling
  }
  rem -= res;
}

The decrement rem -= res at the end of the loop will increase rem in case of an error, which causes all kinds of weird behavior in other places of the code. The correct behavior should be to guard the decrement so that it only happens if we actually managed to read/write to the socket.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions