MXS-1378 Provide access to current session

Provide access to current session and session id. This will
be used by the logging mechanism for logging the session id
together with messages.
This commit is contained in:
Johan Wikman
2017-08-30 10:45:42 +03:00
parent 67efd1daea
commit e7926d770e
2 changed files with 31 additions and 0 deletions

View File

@ -1177,3 +1177,17 @@ json_t* session_list_to_json(const char* host)
dcb_foreach(seslist_cb, &data);
return mxs_json_resource(host, MXS_JSON_API_SESSIONS, data.json);
}
MXS_SESSION* session_get_current()
{
DCB* dcb = dcb_get_current();
return dcb ? dcb->session : NULL;
}
uint64_t session_get_current_id()
{
MXS_SESSION* session = session_get_current();
return session ? session->ses_id : 0;
}