MXS-1220: Fix date formatting

Some of the dates were printed with a trailing newline. This was added by
asctime_r.

Fixed `/services` resource returning an empty array.
This commit is contained in:
Markus Mäkelä
2017-04-17 19:29:00 +03:00
committed by Markus Mäkelä
parent 75b44198ba
commit aa16980cec
3 changed files with 21 additions and 7 deletions

View File

@ -45,6 +45,7 @@
#include <maxscale/router.h>
#include <maxscale/service.h>
#include <maxscale/spinlock.h>
#include <maxscale/utils.h>
#include "maxscale/session.h"
#include "maxscale/filter.h"
@ -1015,8 +1016,11 @@ json_t* session_to_json(const MXS_SESSION *session)
struct tm result;
char buf[60];
json_object_set_new(rval, "connected",
json_string(asctime_r(localtime_r(&session->stats.connect, &result), buf)));
asctime_r(localtime_r(&session->stats.connect, &result), buf);
trim(buf);
json_object_set_new(rval, "connected", json_string(buf));
if (session->client_dcb->state == DCB_STATE_POLLING)
{