-
Notifications
You must be signed in to change notification settings - Fork 183
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
websocket: synchronization between weboscket manager callback and incoming message callback #126
Comments
Hello, If you want to share data between This way you can share a session between those callback functions. struct _ws_stream {
struct config_elements * config;
char * username;
int is_admin;
int is_authenticated;
time_t expiration;
struct _t_webradio * webradio;
struct _t_jukebox * jukebox;
int status;
}; More specifically, if you want, in the
|
Hi, I Think (correct me if I miss something) that that code leaks the malloced handle if you do a normal http request (not websocket) on that endpoint
I now allocate the private data in the manager thread and connect it to the "websocket_manager_user_data" pointer from there. Taking into account a small race condition there, but it's a workable solution for now. If i am mistaking about the above leak, please excuse me and this issue can be closed BR, |
Hello @stefvanos , Concerning the leak, I'm afraid you're right. If you allocate memory and pass it to the By design, I'll make a patch to execute the callback function |
… fixed, otherwise one shouldn't call that a fix, or not a full one, more someting like a half-fix or a semi-fix, or a not-so-fix, pick your best
The leak has been fixed in the commit 47b2b4c , let me know if you have other issues, thanks! |
Hi,
I need to be able to have access to the same per-websocket session data in both the manager (asynchronous writes to websocket) and incoming message callback (reads). For multiple sessions with their own private data, there is no way at the moment to share private data between websocket manager and websocket incoming message callback.
I can think of 2 ways of doing this, but both are not an option at the moment:
This way I could create a pipe in private to notify manager callback that data has arrived from incoming message callback. Currently there is no field in a "struct _websocket_manager" to do this.
I could allocate a private data struct per session before calling "ulfius_set_websocket_response" and provide the same pointer for user data for all 3 callbacks, but if the handshake fails there is no way to know and free the private data (ulfius_set_websocket_response returns U_OK but callbacks are never called)
Skip incoming message callback all-together and do everything from manager callback. I can't find a way to wait for incoming data with poll/select in the current API.
Maybe I'm using ulfius wrong, but is there a way to wait for incoming data (using e.g. poll) in the websocket manager callback?
Best regards, and thanks in advance!
The text was updated successfully, but these errors were encountered: