-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
It's illegal to do an lws_write outside of the writable callback error #852
Comments
The warning is actually coming because you tried to do an lws_write() while another one was only partially sent. The usual way that's happening is people just doing lws_write() randomly. However two or more lws_write() inside the writable callback can also cause it, if the first one was unable to send everything. So you should marshall what you want to write into a buffer and write it once (on lws_write() call) per writable callback. |
even if i use while(lws_partial_buffered(wsi) != 1){/* send here */}? |
Just doing that will protect you against colliding with a pending partial write. But only the first one is guaranteed to be writing when the socket has signalled POLLOUT, ie the attempt to write is related to the state of the network connection. lws_send_pipe_choked(wsi) is better since it checks both pending partial and writability and returns nonzero on either. But if you will handle multiple simultaneous connections it's best to just do one write, ask for the writable callback, and return to the event loop. |
I assume the original problem is solved by one or other of the methods discussed. |
I'm getting "It's illegal to do an lws_write outside of the writable callback: fix your code" error
but the only place i use lws_write in inside the LWS_CALLBACK_CLIENT_WRITEABLE case. am i doing something wrong or is it a bug?
The text was updated successfully, but these errors were encountered: