MXS-2854: Repeat read on schema event

The read needs to be repeated if MaxScale sends a schema event.
This commit is contained in:
Markus Mäkelä
2020-01-28 16:09:31 +02:00
parent ea2665214f
commit a3fd5a0218

View File

@ -449,16 +449,28 @@ SRow Connection::read()
SRow rval; SRow rval;
std::string row; std::string row;
while (true)
{
if (read_row(row)) if (read_row(row))
{ {
json_error_t err; json_error_t err;
json_t* js = json_loads(row.c_str(), JSON_ALLOW_NUL, &err); json_t* js = json_loads(row.c_str(), JSON_ALLOW_NUL, &err);
if (js) if (js)
{
if (is_schema(js))
{
m_schema = row;
process_schema(js);
json_decref(js);
continue;
}
else
{ {
rval = process_row(js); rval = process_row(js);
json_decref(js); json_decref(js);
} }
}
else else
{ {
m_error = "Failed to parse JSON: "; m_error = "Failed to parse JSON: ";
@ -466,6 +478,9 @@ SRow Connection::read()
} }
} }
break;
}
return rval; return rval;
} }