MXS-1220: Implement /sessions/ resource
The /sessions/ resource was not implemented due to changes in the core polling mechanics. With the new worker thread messaging system, sessions can be listed in a safe manner.
This commit is contained in:

committed by
Markus Mäkelä

parent
cd6e0ab5e9
commit
690d592a94
@ -1059,3 +1059,23 @@ json_t* session_to_json(const MXS_SESSION *session, const char *host)
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
struct SessionListData
|
||||
{
|
||||
json_t* json;
|
||||
const char* host;
|
||||
};
|
||||
|
||||
bool seslist_cb(DCB* dcb, void* data)
|
||||
{
|
||||
SessionListData* d = (SessionListData*)data;
|
||||
json_array_append_new(d->json, session_to_json(dcb->session, d->host));
|
||||
return true;
|
||||
}
|
||||
|
||||
json_t* session_list_to_json(const char* host)
|
||||
{
|
||||
SessionListData data = {json_array(), host};
|
||||
dcb_foreach(seslist_cb, &data);
|
||||
return data.json;
|
||||
}
|
||||
|
Reference in New Issue
Block a user