fix broken ext arg parsing

This gets us back to all the Autobahn tests passing

Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
Andy Green 2016-01-19 20:01:33 +08:00
parent d738f84ed1
commit 3f63560876
2 changed files with 14 additions and 8 deletions

View file

@ -749,8 +749,11 @@ check_extensions:
/*
* give the extension the server options
*/
if (a && lws_ext_parse_options(ext, wsi, wsi->act_ext_user[wsi->count_act_ext], opts, a, c - a)) {
lwsl_err("%s: unable to parse remote defaults '%s'", __func__, a);
if (a && lws_ext_parse_options(ext, wsi,
wsi->act_ext_user[wsi->count_act_ext],
opts, a, c - a)) {
lwsl_err("%s: unable to parse remote def '%s'",
__func__, a);
goto bail2;
}
@ -758,7 +761,8 @@ check_extensions:
LWS_EXT_CB_OPTION_CONFIRM,
wsi->act_ext_user[wsi->count_act_ext],
NULL, 0)) {
lwsl_err("%s: ext %s rejects server options %s", ext->name, a);
lwsl_err("%s: ext %s rejects server options %s",
ext->name, a);
goto bail2;
}

View file

@ -21,7 +21,8 @@ enum lws_ext_option_parser_states {
LWS_VISIBLE int
lws_ext_parse_options(const struct lws_extension *ext, struct lws *wsi,
void *ext_user, const struct lws_ext_options *opts, const char *in, int len)
void *ext_user, const struct lws_ext_options *opts,
const char *in, int len)
{
enum lws_ext_option_parser_states leap = LEAPS_SEEK_NAME;
unsigned int match_map = 0, n, m, w = 0, count_options = 0,
@ -31,7 +32,7 @@ lws_ext_parse_options(const struct lws_extension *ext, struct lws *wsi,
while (opts[count_options].name)
count_options++;
while (len) {
lwsl_ext("'%c'", *in);
lwsl_ext("'%c' %d", *in, leap);
switch (leap) {
case LEAPS_SEEK_NAME:
if (*in == ' ')
@ -51,11 +52,10 @@ lws_ext_parse_options(const struct lws_extension *ext, struct lws *wsi,
oa.len = 0;
m = match_map;
n = 0;
w = 0;
pending_close_quote = 0;
while (m) {
if (m & 1) {
// lwsl_ext(" m=%d, n=%d\n", m, n);
lwsl_ext(" m=%d, n=%d, w=%d\n", m, n, w);
if (*in == opts[n].name[w]) {
if (!opts[n].name[w + 1]) {
@ -68,8 +68,10 @@ lws_ext_parse_options(const struct lws_extension *ext, struct lws *wsi,
}
} else {
match_map &= ~(1 << n);
if (!match_map)
if (!match_map) {
lwsl_ext("empty match map\n");
return -1;
}
}
}
m >>= 1;