diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2020-08-15 13:05:49 +0200 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2020-08-15 13:05:49 +0200 |
commit | 84448d5e4e9207835c62fd19a4109f07ad5ca595 (patch) | |
tree | 86aa124e898516f10b96c2916dc9cb539b7e3fd8 | |
parent | 9ab656dbe264b6c216cc9e890a50d9e20b623fa5 (diff) |
error handling enhancements
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
-rw-r--r-- | examples/c-json-stdout/c-json-stdout.c | 1 | ||||
-rw-r--r-- | nDPId.c | 2 | ||||
-rw-r--r-- | nDPIsrvd.c | 7 |
3 files changed, 5 insertions, 5 deletions
diff --git a/examples/c-json-stdout/c-json-stdout.c b/examples/c-json-stdout/c-json-stdout.c index 83af9d12d..18c50a491 100644 --- a/examples/c-json-stdout/c-json-stdout.c +++ b/examples/c-json-stdout/c-json-stdout.c @@ -112,6 +112,7 @@ int main(void) { fprintf(stderr, "JSON parsing failed with return value %d at position %u\n", r, parser.pos); fprintf(stderr, "JSON string: '%.*s'\n", (int)(json_bytes - json_start), (char *)(buf + json_start)); + exit(1); } for (int i = 1; i < r; i++) @@ -729,7 +729,7 @@ static void send_to_json_sink(struct nDPId_reader_thread * const reader_thread, } errno = 0; - if (reader_thread->json_sock_reconnect == 0 && write(reader_thread->json_sockfd, newline_json_str, s_ret) <= 0) + if (reader_thread->json_sock_reconnect == 0 && write(reader_thread->json_sockfd, newline_json_str, s_ret) != s_ret) { saved_errno = errno; syslog(LOG_DAEMON | LOG_ERR, diff --git a/nDPIsrvd.c b/nDPIsrvd.c index cb38d7b87..63cf8da0e 100644 --- a/nDPIsrvd.c +++ b/nDPIsrvd.c @@ -166,7 +166,8 @@ static void disconnect_client(int epollfd, struct remote_desc * const current) { if (epoll_ctl(epollfd, EPOLL_CTL_DEL, current->fd, NULL) < 0) { - syslog(LOG_DAEMON | LOG_ERR, "Error deleting fd from epollq: %s", strerror(errno)); + syslog(LOG_DAEMON | LOG_ERR, "Error deleting fd %d from epollq %d: %s", + current->fd, epollfd, strerror(errno)); } if (close(current->fd) != 0) { @@ -446,9 +447,7 @@ int main(int argc, char ** argv) } if (bytes_read == 0) { - syslog(LOG_DAEMON, - "%s connection closed during read", - (current->type == JSON_SOCK ? "collector" : "distributor")); + syslog(LOG_DAEMON, "collector connection closed during read"); disconnect_client(epollfd, current); continue; } |