diff options
author | Federico Ceratto <federico.ceratto@gmail.com> | 2018-03-27 21:28:27 +0000 |
---|---|---|
committer | Federico Ceratto <federico.ceratto@gmail.com> | 2018-03-27 21:28:27 +0000 |
commit | eb7cc2640201f168bbd9a05799fd2dbe823bb57c (patch) | |
tree | 1f88da02b7ee3c16ced7b5f7dc4aadb190766e7c /src/common.c | |
parent | Release v. 1.9.0+dfsg-1 to Unstable (diff) | |
parent | New upstream version 1.10.0+dfsg (diff) | |
download | netdata-eb7cc2640201f168bbd9a05799fd2dbe823bb57c.tar.xz netdata-eb7cc2640201f168bbd9a05799fd2dbe823bb57c.zip |
Update upstream source from tag 'upstream/1.10.0+dfsg'
Update to upstream version '1.10.0+dfsg'
with Debian dir fa5485f3d9aea3038a19eff06ba33374ac5c5d7c
Diffstat (limited to 'src/common.c')
-rw-r--r-- | src/common.c | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/src/common.c b/src/common.c index a976e96eb..94fd5e429 100644 --- a/src/common.c +++ b/src/common.c @@ -19,6 +19,7 @@ char *netdata_configured_home_dir = NULL; char *netdata_configured_host_prefix = NULL; char *netdata_configured_timezone = NULL; +struct rlimit rlimit_nofile = { .rlim_cur = 1024, .rlim_max = 1024 }; int enable_ksm = 1; volatile sig_atomic_t netdata_exit = 0; @@ -904,6 +905,30 @@ void strreverse(char *begin, char *end) { } } +char *strsep_on_1char(char **ptr, char c) { + if(unlikely(!ptr || !*ptr)) + return NULL; + + // remember the position we started + char *s = *ptr; + + // skip separators in front + while(*s == c) s++; + char *ret = s; + + // find the next separator + while(*s++) { + if(unlikely(*s == c)) { + *s++ = '\0'; + *ptr = s; + return ret; + } + } + + *ptr = NULL; + return ret; +} + char *mystrsep(char **ptr, char *s) { char *p = ""; while (p && !p[0] && *ptr) p = strsep(ptr, s); @@ -1116,22 +1141,6 @@ int fd_is_valid(int fd) { return fcntl(fd, F_GETFD) != -1 || errno != EBADF; } -pid_t gettid(void) { -#ifdef __FreeBSD__ - return (pid_t)pthread_getthreadid_np(); -#elif defined(__APPLE__) -#if (defined __MAC_OS_X_VERSION_MIN_REQUIRED && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060) - uint64_t curthreadid; - pthread_threadid_np(NULL, &curthreadid); - return (pid_t)curthreadid; -#else /* __MAC_OS_X_VERSION_MIN_REQUIRED */ - return (pid_t)pthread_self; -#endif /* __MAC_OS_X_VERSION_MIN_REQUIRED */ -#else /* __APPLE__*/ - return (pid_t)syscall(SYS_gettid); -#endif /* __FreeBSD__, __APPLE__*/ -} - char *fgets_trim_len(char *buf, size_t buf_size, FILE *fp, size_t *len) { char *s = fgets(buf, (int)buf_size, fp); if (!s) return NULL; |