mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
server-status: still produce valid json if files cant be opened
Kernel update changed the /sys path for temp monitoring... the status had already emitted a , in the json committing it to make a new entry, but the code skips making it if the file can't be opened. Change it to produce "(unknown)" in that case.
This commit is contained in:
parent
a97347a18e
commit
d3aa28c2db
1 changed files with 7 additions and 6 deletions
|
@ -75,21 +75,22 @@ update(struct vhd *v)
|
|||
if (!first)
|
||||
p += lws_snprintf(p, lws_ptr_diff(end, p), ",");
|
||||
|
||||
strcpy(pure, "(unknown)");
|
||||
fd = lws_open(fp->filepath, LWS_O_RDONLY);
|
||||
if (fd >= 0) {
|
||||
n = read(fd, contents, sizeof(contents) - 1);
|
||||
close(fd);
|
||||
if (n >= 0) {
|
||||
contents[n] = '\0';
|
||||
lws_json_purify(pure, contents, sizeof(pure));
|
||||
|
||||
p += lws_snprintf(p, lws_ptr_diff(end, p),
|
||||
"{\"path\":\"%s\",\"val\":\"%s\"}",
|
||||
fp->filepath, pure);
|
||||
first = 0;
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
|
||||
p += lws_snprintf(p, lws_ptr_diff(end, p),
|
||||
"{\"path\":\"%s\",\"val\":\"%s\"}",
|
||||
fp->filepath, pure);
|
||||
first = 0;
|
||||
|
||||
fp = fp->next;
|
||||
}
|
||||
p += lws_snprintf(p, lws_ptr_diff(end, p), "]}");
|
||||
|
|
Loading…
Add table
Reference in a new issue