Skip to content

Commit 3ba91b5

Browse files
mindflayerCopilot
andauthored
Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 7f5f281 commit 3ba91b5

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

mocket/socket.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,9 +621,13 @@ def recv(self, buffersize: int, flags: int | None = None) -> bytes:
621621
r_fd, _ = Mocket.get_pair(address)
622622
if r_fd and Mocket.pipe_uses_data(address):
623623
try:
624-
return os.read(r_fd, buffersize)
624+
pipe_data = os.read(r_fd, buffersize)
625625
except BlockingIOError:
626-
pass
626+
pipe_data = b""
627+
if pipe_data:
628+
# Keep in-memory buffer position in sync with bytes drained from the pipe.
629+
self.io.seek(self.io.tell() + len(pipe_data))
630+
return pipe_data
627631

628632
pending = Mocket.get_pending_readables(address)
629633
if r_fd and self._buffered_bytes() and pending == 0:

0 commit comments

Comments
 (0)