Skip to content

Make SOC services thread-safe#601

Open
ZeroSkill1 wants to merge 1 commit intodevkitPro:masterfrom
ZeroSkill1:soc-mt-fix
Open

Make SOC services thread-safe#601
ZeroSkill1 wants to merge 1 commit intodevkitPro:masterfrom
ZeroSkill1:soc-mt-fix

Conversation

@ZeroSkill1
Copy link
Copy Markdown
Contributor

@ZeroSkill1 ZeroSkill1 commented Mar 22, 2026

As it stands, the soc:U client-side implementation in libctru will break when used across more than one thread. This is because while one thread is sending a soc:U command, all others would be blocked if they use those commands until that thread is finished with it.

Official system modules such as friends and http allocate a pool of soc:U handles and implement a "give/take" system, where handles are popped from the pool, used for a command, then reinserted afterwards.

I have implemented a similar kind of handle pool, with backwards compatibility by making the usual socInit initialize only one session, and implementing a new function socInitMulti to provide the user with control for how many sessions should be allocated depending on the use case.

I've tested this change to be working with:

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.

1 participant