X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fsessiond-comm%2Finet.c;h=2c959c5fe81ee08d21cca8f0ac42a62d0dfecb6c;hb=22fb211b5ad4d39789f782180a5e610b72a20291;hp=b5a016e6f54fd46e3eb297b02c94c192cefe995a;hpb=d831c2497e9e8b2360cbe2026fdb2d736fa07641;p=lttng-tools.git diff --git a/src/common/sessiond-comm/inet.c b/src/common/sessiond-comm/inet.c index b5a016e6f..2c959c5fe 100644 --- a/src/common/sessiond-comm/inet.c +++ b/src/common/sessiond-comm/inet.c @@ -457,6 +457,7 @@ int lttcomm_close_inet_sock(struct lttcomm_sock *sock) static unsigned long read_proc_value(const char *path) { int ret, fd; + ssize_t size_ret; long r_val; unsigned long val = 0; char buf[64]; @@ -466,11 +467,16 @@ static unsigned long read_proc_value(const char *path) goto error; } - ret = read(fd, buf, sizeof(buf)); - if (ret < 0) { + size_ret = lttng_read(fd, buf, sizeof(buf)); + /* + * Allow reading a file smaller than buf, but keep space for + * final \0. + */ + if (size_ret < 0 || size_ret >= sizeof(buf)) { PERROR("read proc failed"); goto error_close; } + buf[size_ret] = '\0'; errno = 0; r_val = strtol(buf, NULL, 10); @@ -495,7 +501,13 @@ error: LTTNG_HIDDEN void lttcomm_inet_init(void) { - unsigned long syn_retries, fin_timeout, syn_timeout; + unsigned long syn_retries, fin_timeout, syn_timeout, env; + + env = lttcomm_get_network_timeout(); + if (env) { + lttcomm_inet_tcp_timeout = env; + goto end; + } /* Assign default value and see if we can change it. */ lttcomm_inet_tcp_timeout = DEFAULT_INET_TCP_TIMEOUT; @@ -513,5 +525,6 @@ void lttcomm_inet_init(void) max_t(unsigned long, syn_timeout, fin_timeout), lttcomm_inet_tcp_timeout); +end: DBG("TCP inet operation timeout set to %lu sec", lttcomm_inet_tcp_timeout); }