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
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19

View File

@ -170,7 +170,7 @@ void Closer<int>::close(int fd)
namespace CDC
{
const char* const TIMEOUT = "Request timed out";
const char* const TIMEOUT = "Request timed out";
/**
* Public functions
@ -449,21 +449,36 @@ SRow Connection::read()
SRow rval;
std::string row;
if (read_row(row))
while (true)
{
json_error_t err;
json_t* js = json_loads(row.c_str(), JSON_ALLOW_NUL, &err);
if (read_row(row))
{
json_error_t err;
json_t* js = json_loads(row.c_str(), JSON_ALLOW_NUL, &err);
if (js)
{
rval = process_row(js);
json_decref(js);
}
else
{
m_error = "Failed to parse JSON: ";
m_error += err.text;
if (js)
{
if (is_schema(js))
{
m_schema = row;
process_schema(js);
json_decref(js);
continue;
}
else
{
rval = process_row(js);
json_decref(js);
}
}
else
{
m_error = "Failed to parse JSON: ";
m_error += err.text;
}
}
break;
}
return rval;