mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
ws role: cannot assume sentinel, use vhost count
Protocol list is no longer a simple sentinel-terminated array but composed at vhost creation time in many cases. Use the vhost's count of how many protocols it has rather than seeking up to the sentinel.
This commit is contained in:
parent
49f78ed0d7
commit
72e31ba5f7
2 changed files with 3 additions and 3 deletions
|
@ -1516,7 +1516,7 @@ lws_http_action(struct lws *wsi)
|
|||
if (lws_bind_protocol(wsi, pp, "http action CALLBACK bind"))
|
||||
return 1;
|
||||
|
||||
lwsl_notice("%s: %s, checking access rights for mask 0x%x\n",
|
||||
lwsl_debug("%s: %s, checking access rights for mask 0x%x\n",
|
||||
__func__, hit->origin, hit->auth_mask);
|
||||
|
||||
args.p = uri_ptr;
|
||||
|
|
|
@ -391,7 +391,7 @@ identify_protocol:
|
|||
if (!lwsi_role_client(wsi))
|
||||
wsi->protocol = NULL;
|
||||
|
||||
while (wsi->vhost->protocols[n].callback) {
|
||||
while (n < wsi->vhost->count_protocols) {
|
||||
if (!wsi->protocol &&
|
||||
strcmp(p, wsi->vhost->protocols[n].name) == 0) {
|
||||
wsi->protocol = &wsi->vhost->protocols[n];
|
||||
|
@ -400,7 +400,7 @@ identify_protocol:
|
|||
n++;
|
||||
}
|
||||
|
||||
if (!wsi->vhost->protocols[n].callback) { /* no match */
|
||||
if (n == wsi->vhost->count_protocols) { /* no match */
|
||||
/* if server, that's already fatal */
|
||||
if (!lwsi_role_client(wsi)) {
|
||||
lwsl_info("%s: fail protocol %s\n", __func__, p);
|
||||
|
|
Loading…
Add table
Reference in a new issue