Skip to content

Commit

Permalink
feat!: modify recv/recvfrom/recvinto behavior
Browse files Browse the repository at this point in the history
Previously, these functions would wait until the entire requested number of bytes was filled before returning. With this change, they will now return as soon as they have read the available data, even if it's less than the requested amount.
  • Loading branch information
jacopodl committed Jul 26, 2023
1 parent 749ee35 commit 1e34266
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions argon/vm/io/socket/psocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ CallbackReturnStatus RecvCallBack(Event *event) {
return CallbackReturnStatus::RETRY;
}

event->buffer.length += bytes;
if (bytes > 0 && event->buffer.length < event->buffer.allocated)
return CallbackReturnStatus::RETRY;
event->buffer.length = bytes;

auto *buffer = BytesNewHoldBuffer(event->buffer.data, event->buffer.allocated, event->buffer.length, true);
if (buffer == nullptr) {
Expand Down Expand Up @@ -153,9 +151,7 @@ CallbackReturnStatus RecvFromCallBack(Event *event) {
return CallbackReturnStatus::RETRY;
}

event->buffer.length += bytes;
if (sock->type != SOCK_DGRAM && bytes > 0 && event->buffer.length < event->buffer.allocated)
return CallbackReturnStatus::RETRY;
event->buffer.length = bytes;

auto *remote_addr = SockAddrToAddr(&storage, sock->family);
if (remote_addr == nullptr) {
Expand Down Expand Up @@ -209,9 +205,7 @@ CallbackReturnStatus RecvIntoCallBack(Event *event) {
return CallbackReturnStatus::RETRY;
}

event->buffer.length += bytes;
if (bytes > 0 && event->buffer.length < event->buffer.allocated)
return CallbackReturnStatus::RETRY;
event->buffer.length = bytes;

auto *buffer = IntNew((IntegerUnderlying) event->buffer.length);

Expand Down

0 comments on commit 1e34266

Please sign in to comment.