From: Travis Cross Date: Sun, 2 Mar 2014 22:20:20 +0000 (+0000) Subject: Output newline after json output in mod_json_cdr X-Git-Tag: v1.5.11~164 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ecd6dfc612b8c0af03df8864eeb95080bd7a31ea;p=thirdparty%2Ffreeswitch.git Output newline after json output in mod_json_cdr In UNIX, text files by definition end with a newline. --- diff --git a/src/mod/event_handlers/mod_json_cdr/mod_json_cdr.c b/src/mod/event_handlers/mod_json_cdr/mod_json_cdr.c index 2d08f5175a..df9336f302 100644 --- a/src/mod/event_handlers/mod_json_cdr/mod_json_cdr.c +++ b/src/mod/event_handlers/mod_json_cdr/mod_json_cdr.c @@ -217,6 +217,8 @@ static void backup_cdr(cdr_data_t *data) switch_ssize_t wrote = 0, x; do { x = write(fd, json_text, json_len); } while (!(x<0) && json_len > (wrote += x)); + if (!(x<0)) do { x = write(fd, "\n", 1); + } while (!(x<0) && x<1); close(fd); fd = -1; if (x < 0) { switch_log_printf(SWITCH_CHANNEL_UUID_LOG(data->uuid), SWITCH_LOG_ERROR, "Error writing [%s]\n",path); @@ -281,6 +283,8 @@ static void process_cdr(cdr_data_t *data) switch_ssize_t wrote = 0, x; do { x = write(fd, data->json_text, json_len); } while (!(x<0) && json_len > (wrote += x)); + if (!(x<0)) do { x = write(fd, "\n", 1); + } while (!(x<0) && x<1); close(fd); fd = -1; if (x < 0) { switch_log_printf(SWITCH_CHANNEL_UUID_LOG(data->uuid), SWITCH_LOG_ERROR, "Error writing [%s]\n",path);