Browse Source

Use JSON_EOL in generator

master
Con Kolivas 10 years ago
parent
commit
5c18e7e0f8
  1. 6
      src/generator.c

6
src/generator.c

@ -1,5 +1,5 @@
/* /*
* Copyright 2014 Con Kolivas * Copyright 2014-2015 Con Kolivas
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free * under the terms of the GNU General Public License as published by the Free
@ -388,13 +388,11 @@ static bool send_json_msg(connsock_t *cs, json_t *json_msg)
int len, sent; int len, sent;
char *s; char *s;
s = json_dumps(json_msg, JSON_ESCAPE_SLASH); s = json_dumps(json_msg, JSON_ESCAPE_SLASH | JSON_EOL);
LOGDEBUG("Sending json msg: %s", s); LOGDEBUG("Sending json msg: %s", s);
len = strlen(s); len = strlen(s);
sent = write_socket(cs->fd, s, len); sent = write_socket(cs->fd, s, len);
len += 1;
dealloc(s); dealloc(s);
sent += write_socket(cs->fd, "\n", 1);
if (sent != len) { if (sent != len) {
LOGWARNING("Failed to send %d bytes sent %d in send_json_msg", len, sent); LOGWARNING("Failed to send %d bytes sent %d in send_json_msg", len, sent);
return false; return false;

Loading…
Cancel
Save