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

Report fail if binding to a socket fails in websockets #2534

Merged
merged 4 commits into from
Jan 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions transports/janus_websockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,9 @@ int janus_websockets_init(janus_transport_callbacks *callback, const char *confi
info.ssl_private_key_password = NULL;
info.gid = -1;
info.uid = -1;
info.options = 0;
#if (LWS_LIBRARY_VERSION_MAJOR == 3 && LWS_LIBRARY_VERSION_MINOR >= 2) || (LWS_LIBRARY_VERSION_MAJOR > 3)
info.options = LWS_SERVER_OPTION_FAIL_UPON_UNABLE_TO_BIND;
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation seems broken? Please use tabs, not spaces (code style nit).
As a side note, no need for the else part with the 0 init: we already memset the whole info object to 0 when we declare the variable.

/* Create the WebSocket context */
wss = lws_create_vhost(wsc, &info);
if(wss == NULL) {
Expand Down Expand Up @@ -701,10 +703,10 @@ int janus_websockets_init(janus_transport_callbacks *callback, const char *confi
info.ssl_cipher_list = ciphers;
info.gid = -1;
info.uid = -1;
#if LWS_LIBRARY_VERSION_MAJOR >= 2
#if (LWS_LIBRARY_VERSION_MAJOR == 3 && LWS_LIBRARY_VERSION_MINOR >= 2) || (LWS_LIBRARY_VERSION_MAJOR > 3)
info.options = LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT | LWS_SERVER_OPTION_FAIL_UPON_UNABLE_TO_BIND;
#elif LWS_LIBRARY_VERSION_MAJOR >= 2
info.options = LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT;
#else
info.options = 0;
#endif
/* Create the secure WebSocket context */
swss = lws_create_vhost(wsc, &info);
Expand Down Expand Up @@ -753,7 +755,9 @@ int janus_websockets_init(janus_transport_callbacks *callback, const char *confi
info.ssl_private_key_password = NULL;
info.gid = -1;
info.uid = -1;
info.options = 0;
#if (LWS_LIBRARY_VERSION_MAJOR == 3 && LWS_LIBRARY_VERSION_MINOR >= 2) || (LWS_LIBRARY_VERSION_MAJOR > 3)
info.options = LWS_SERVER_OPTION_FAIL_UPON_UNABLE_TO_BIND;
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

/* Create the WebSocket context */
admin_wss = lws_create_vhost(wsc, &info);
if(admin_wss == NULL) {
Expand Down Expand Up @@ -818,10 +822,10 @@ int janus_websockets_init(janus_transport_callbacks *callback, const char *confi
info.ssl_cipher_list = ciphers;
info.gid = -1;
info.uid = -1;
#if LWS_LIBRARY_VERSION_MAJOR >= 2
#if (LWS_LIBRARY_VERSION_MAJOR == 3 && LWS_LIBRARY_VERSION_MINOR >= 2) || (LWS_LIBRARY_VERSION_MAJOR > 3)
info.options = LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT | LWS_SERVER_OPTION_FAIL_UPON_UNABLE_TO_BIND;
#elif LWS_LIBRARY_VERSION_MAJOR >= 2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. There's also an extra space after the equal sign that shouldn't be there.

info.options = LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT;
#else
info.options = 0;
#endif
/* Create the secure WebSocket context */
admin_swss = lws_create_vhost(wsc, &info);
Expand Down