mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
vhost: bind: make failure to bind optionally fatal
When creating a vhost and the port is already bound to another process this flag would allow the user code to choose to have the lws_create_vhost function to fail and return a null pointer.
This commit is contained in:
parent
0ada40ce92
commit
0123b4381f
2 changed files with 8 additions and 2 deletions
|
@ -203,6 +203,10 @@ enum lws_context_options {
|
|||
* on the client using http when he meant https... it's not
|
||||
* recommended.
|
||||
*/
|
||||
LWS_SERVER_OPTION_FAIL_UPON_UNABLE_TO_BIND = (1 << 30),
|
||||
/**< (VH) When instantiating a new vhost and the specified port is
|
||||
* already in use, a null value shall be return to signal the error.
|
||||
*/
|
||||
|
||||
/****** add new things just above ---^ ******/
|
||||
};
|
||||
|
|
|
@ -130,13 +130,15 @@ done_list:
|
|||
if (info) /* first time */
|
||||
lwsl_err("VH %s: iface %s port %d DOESN'T EXIST\n",
|
||||
vhost->name, vhost->iface, vhost->listen_port);
|
||||
return 1;
|
||||
return (info->options & LWS_SERVER_OPTION_FAIL_UPON_UNABLE_TO_BIND) == LWS_SERVER_OPTION_FAIL_UPON_UNABLE_TO_BIND?
|
||||
-1 : 1;
|
||||
case LWS_ITOSA_NOT_USABLE:
|
||||
/* can't add it */
|
||||
if (info) /* first time */
|
||||
lwsl_err("VH %s: iface %s port %d NOT USABLE\n",
|
||||
vhost->name, vhost->iface, vhost->listen_port);
|
||||
return 1;
|
||||
return (info->options & LWS_SERVER_OPTION_FAIL_UPON_UNABLE_TO_BIND) == LWS_SERVER_OPTION_FAIL_UPON_UNABLE_TO_BIND?
|
||||
-1 : 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue