|
@@ -12,6 +12,7 @@
|
12
|
12
|
#include <stdio.h>
|
13
|
13
|
#include <stdlib.h>
|
14
|
14
|
#include <stdarg.h>
|
|
15
|
+#include <stdbool.h>
|
15
|
16
|
#include <unistd.h>
|
16
|
17
|
#include <string.h>
|
17
|
18
|
#include <netdb.h>
|
|
@@ -31,6 +32,12 @@
|
31
|
32
|
#include "libfuncs.h"
|
32
|
33
|
#include "log.h"
|
33
|
34
|
|
|
35
|
+static int io_report_errors = 1;
|
|
36
|
+
|
|
37
|
+void set_log_io_errors(int report_io_errors) {
|
|
38
|
+ io_report_errors = report_io_errors;
|
|
39
|
+}
|
|
40
|
+
|
34
|
41
|
char * chomp(char *x) {
|
35
|
42
|
int i=strlen(x)-1;
|
36
|
43
|
while ((i>=0)&&((x[i]=='\n')||(x[i]=='\r')||(x[i]==' ')||(x[i]=='\t'))){
|
|
@@ -88,7 +95,8 @@ ssize_t fdgetline(int fd, char *buf, size_t buf_size) {
|
88
|
95
|
if (num_timeouts++ <= FDGETLINE_RETRIES) {
|
89
|
96
|
continue;
|
90
|
97
|
} else {
|
91
|
|
- log_perror("fdgetline() timeout", errno);
|
|
98
|
+ if (io_report_errors)
|
|
99
|
+ log_perror("fdgetline() timeout", errno);
|
92
|
100
|
}
|
93
|
101
|
}
|
94
|
102
|
if (fdready == 0 || fdready == -1) { /* Timeout || error */
|
|
@@ -129,7 +137,7 @@ ssize_t fdread_ex(int fd, char *buf, size_t buf_size, int timeout, int retries,
|
129
|
137
|
if (num_timeouts++ <= retries) {
|
130
|
138
|
continue;
|
131
|
139
|
} else {
|
132
|
|
- if (timeout) {
|
|
140
|
+ if (timeout && io_report_errors) {
|
133
|
141
|
log_perror("fdread() timeout", errno);
|
134
|
142
|
}
|
135
|
143
|
return rbytes > 0 ? rbytes : -1;
|
|
@@ -183,7 +191,8 @@ ssize_t fdwrite(int fd, char *buf, size_t buf_size) {
|
183
|
191
|
if (num_timeouts++ <= FDWRITE_RETRIES) {
|
184
|
192
|
continue;
|
185
|
193
|
} else {
|
186
|
|
- log_perror("fdwrite() timeout", errno);
|
|
194
|
+ if (io_report_errors)
|
|
195
|
+ log_perror("fdwrite() timeout", errno);
|
187
|
196
|
return wbytes > 0 ? wbytes : -1;
|
188
|
197
|
}
|
189
|
198
|
}
|