Skip to content

net: do wii network transfers in blocks (#178) - #31

Open
dborth wants to merge 1 commit into
extremscorner:masterfrom
dborth:master
Open

dborth wants to merge 1 commit into
extremscorner:masterfrom
dborth:master

Conversation

@dborth

@dborth dborth commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

a PR was recently submitted to me - dborth/libsmb2#2

the problem - net_recvfrom and net_sendto are neither bound nor gracefully handle large sizes.

looks like others have hit this before so I pulled the working fix from dacotaco (devkitPro/libogc@f4dbfca)

@Extrems

Extrems commented Oct 13, 2026

Copy link
Copy Markdown
Member

I don't believe this memory copy is required to begin with, certainly not from/to MEM2. I'll have to check for MEM1.

@TeleTubby666

Copy link
Copy Markdown

Thanks for picking this up. I reported the original issue in
dborth/libsmb2#2 (real Wii, Samba 4, SMB2/3). I read through the diff and
have two observations:

  1. Splitting into blocks fixes the IPC_ENOMEM (-22) on large requests, which
    was one of the two problems I saw. The other was a hang right after the
    TCP connect: libsmb2's read loop expects EAGAIN when no data is pending
    on a non-blocking socket, but net_read() -> net_recvfrom() with flags 0
    did not give me that. I worked around it by calling net_select() with a
    zero timeout first and returning EAGAIN if nothing is readable. This
    patch doesn't change that behaviour, so I'd expect the hang to remain.

  2. In the new loop, if len > maxblocksize and the first block comes back
    full, the loop calls recvfrom again immediately. If no more data is
    pending, that call either blocks or returns -EAGAIN, and since
    ret = received overwrites the count, the data already read is lost.
    Returning the bytes read so far (when ret > 0) would avoid that. The same
    applies to net_sendto if a later block fails.

I haven't tested this PR build on hardware yet. Since dborth/libsmb2#2 was
closed in favour of this, I'd suggest keeping the EAGAIN/readability check
in mind until it's confirmed that the hang is gone with this change alone.
I'll report back with test results on hardware as soon as I'm home on
Friday.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants