diff options
Diffstat (limited to 'xlators/features/changelog/lib/src/gf-changelog-helpers.c')
| -rw-r--r-- | xlators/features/changelog/lib/src/gf-changelog-helpers.c | 51 | 
1 files changed, 4 insertions, 47 deletions
diff --git a/xlators/features/changelog/lib/src/gf-changelog-helpers.c b/xlators/features/changelog/lib/src/gf-changelog-helpers.c index 03dac5e4729..e5a9db4dd0f 100644 --- a/xlators/features/changelog/lib/src/gf-changelog-helpers.c +++ b/xlators/features/changelog/lib/src/gf-changelog-helpers.c @@ -64,20 +64,7 @@ gf_rfc3986_encode_space_newline(unsigned char *s, char *enc, char *estr)   *       made a part of libglusterfs.   */ -static pthread_key_t rl_key; -static pthread_once_t rl_once = PTHREAD_ONCE_INIT; - -static void -readline_destructor(void *ptr) -{ -    GF_FREE(ptr); -} - -static void -readline_once(void) -{ -    pthread_key_create(&rl_key, readline_destructor); -} +static __thread read_line_t thread_tsd = {};  static ssize_t  my_read(read_line_t *tsd, int fd, char *ptr) @@ -97,27 +84,6 @@ my_read(read_line_t *tsd, int fd, char *ptr)      return 1;  } -static int -gf_readline_init_once(read_line_t **tsd) -{ -    if (pthread_once(&rl_once, readline_once) != 0) -        return -1; - -    *tsd = pthread_getspecific(rl_key); -    if (*tsd) -        goto out; - -    *tsd = GF_CALLOC(1, sizeof(**tsd), gf_changelog_mt_libgfchangelog_rl_t); -    if (!*tsd) -        return -1; - -    if (pthread_setspecific(rl_key, *tsd) != 0) -        return -1; - -out: -    return 0; -} -  ssize_t  gf_readline(int fd, void *vptr, size_t maxlen)  { @@ -125,10 +91,7 @@ gf_readline(int fd, void *vptr, size_t maxlen)      size_t rc = 0;      char c = ' ';      char *ptr = NULL; -    read_line_t *tsd = NULL; - -    if (gf_readline_init_once(&tsd)) -        return -1; +    read_line_t *tsd = &thread_tsd;      ptr = vptr;      for (n = 1; n < maxlen; n++) { @@ -151,10 +114,7 @@ off_t  gf_lseek(int fd, off_t offset, int whence)  {      off_t off = 0; -    read_line_t *tsd = NULL; - -    if (gf_readline_init_once(&tsd)) -        return -1; +    read_line_t *tsd = &thread_tsd;      off = sys_lseek(fd, offset, whence);      if (off == -1) @@ -169,10 +129,7 @@ gf_lseek(int fd, off_t offset, int whence)  int  gf_ftruncate(int fd, off_t length)  { -    read_line_t *tsd = NULL; - -    if (gf_readline_init_once(&tsd)) -        return -1; +    read_line_t *tsd = &thread_tsd;      if (sys_ftruncate(fd, 0))          return -1;  | 
