Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ff_send data with large data with blocking-socket will fail #709

Closed
renzibei opened this issue Oct 26, 2022 · 5 comments
Closed

ff_send data with large data with blocking-socket will fail #709

renzibei opened this issue Oct 26, 2022 · 5 comments
Labels

Comments

@renzibei
Copy link
Contributor

I found that when I tried to use blocking socket with kqueue and sent a large data (e.g. 65536 bytes), the ff_send would simply fail because the sbwait in uipc_sockbuf.c:449 (which calls a fake sleep function _sleep in ff_kern_synch.c:91) returns 1.

As the developer responded in #30, I agree that it's not recommended to use blocking socket with kqueue. However, in real freebsd kernel, it is allowed to doing this. I think even if f-stack chooses to forbid this kind of usage, it should be noted in the documents. For example, how can the users know this will fail? And how large is the one-time sending length limit?

@MrSonicMaster
Copy link

blocking sockets do not make much sense in f-stack architecture, since it operates entirely single-threaded, with the kernel code being indifferent from the application code. blocking only makes sense if the task your sleeping on can actually be carried out concurrent with the sleeping.

@renzibei
Copy link
Contributor Author

renzibei commented Oct 27, 2022

Thank you for reply. After these days of research I have basically figured this out more or less. That is to say, the programming mode of f-stack is fixedly driven by the event loop. What I'm still unclear about though is whether setting the socket to blocking mode or not makes any difference. Will the recv operation of a blocked socket cause sleep? According to my understanding f-stack uses the busy poll mode. So will it actually go to sleep state in recv? If it is said that sockets in non-blocking mode should be used everywhere, why is the socket not set to non-blocking mode in example/main.c?

Also like I said, I can understand such a design. But such limitations on functions and differences in behavior from standard POSIX operations should be documented. Otherwise the user cannot know the consequences in advance.

@MrSonicMaster
Copy link

I do agree, f-stack is not well documented, in many cases is unpolished, and perhaps is to be considered more of a DIY-type library for any features that tencent does not rely on themselves. I am, of course, still appreciative that their current progress has been made public. I am unsure why the example does not suggest to use non-blocking sockets, or in which cases a blocking socket will run into issues, but I presume tencent did little work/testing involving them and therefore it is unsafe to use them.

@jfb8856606
Copy link
Contributor

Appropriate instructions will be added to the document for this part of the content, but it may not be very perfect.

jfb8856606 added a commit that referenced this issue Feb 17, 2023
2. Add some description of `ff_socket()` and `ff_write()`.
3. Ref #709.
@jfb8856606
Copy link
Contributor

Added a simple description in ff_api.h and set non blocking in example/main.c in default, close this issue first.

anvayabn pushed a commit to anvayabn/f-stack that referenced this issue Jul 13, 2023
2. Add some description of `ff_socket()` and `ff_write()`.
3. Ref F-Stack#709.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants