]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common: Remove common/tls.cc
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Mon, 14 Feb 2011 13:14:36 +0000 (05:14 -0800)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Mon, 14 Feb 2011 13:51:05 +0000 (05:51 -0800)
Using ELF TLS via the __thread keyword is much faster than using
pthread_getspecific and pthread_setspecific. It's also much nicer
looking syntactically. Finally, the __thread keyword is going to be
standardized in C++0x. So there's no reason to have an infrastructure
dependent on pthread_getspecific.

There were no users so this shouldn't affect anything negatively.

Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
src/Makefile.am
src/common/assert.cc
src/common/common_init.cc
src/common/tls.cc [deleted file]
src/common/tls.h [deleted file]

index 2a6fe8a0aece29b2b6a56aee07fa411080f16e48..8bffa32663cf4c91fa22f2057f5a3bc3968add87 100644 (file)
@@ -519,7 +519,6 @@ libcommon_files = \
        mon/MonClient.cc \
        osd/OSDMap.cc \
        mds/MDSMap.cc \
-       common/tls.cc \
        common/common_init.cc \
        common/buffer.cc \
        common/signal.cc \
@@ -677,7 +676,6 @@ noinst_HEADERS = \
         common/dyn_snprintf.h\
         common/run_cmd.h\
        common/safe_io.h\
-        common/tls.h\
         config.h\
         crush/CrushWrapper.h\
         crush/CrushWrapper.i\
index 6b83c522953de2650b2fec8869152b3eb2ab1e91..dc3fedb8d9a4f98fd96c81138adcee27124ad153 100644 (file)
@@ -4,8 +4,6 @@
 
 #include "BackTrace.h"
 
-#include "common/tls.h"
-
 namespace ceph {
 
 void __ceph_assert_fail(const char *assertion, const char *file, int line, const char *func)
index 65f138076663449dc7dd994baea8066a606c1526..1fc60085548efe8a1caeb1ed3a54b7d10918aa03 100644 (file)
@@ -20,7 +20,6 @@
 #include "common/errno.h"
 #include "common/signal.h"
 #include "include/color.h"
-#include "tls.h"
 
 /* Set foreground logging
  *
@@ -112,9 +111,6 @@ static void keyring_init(const char *filesearch)
 
 void common_init(std::vector<const char*>& args, const char *module_type, int flags)
 {
-  tls_init();
-  tls_get_val()->disable_assert = 0;
-
   parse_startup_config_options(args, module_type, flags);
   parse_config_options(args);
   install_standard_sighandlers();
diff --git a/src/common/tls.cc b/src/common/tls.cc
deleted file mode 100644 (file)
index 3c6f9c7..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-#include <pthread.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "common/tls.h"
-
-#include "config.h"
-
-#undef dout
-#undef derr
-#define  dout(l)    if (l<=g_conf.debug_lockdep) *_dout << g_clock.now() << " " << std::hex << pthread_self() << std::dec << " tls: "
-#define  derr(l)    if (l<=g_conf.debug_lockdep) *_derr << g_clock.now() << " " << std::hex << pthread_self() << std::dec << " tls: "
-
-
-pthread_key_t   _tls_key = 0;
-
-static int _initialized = 0;
-
-static void _tls_destructor(void *value)
-{
-  free(value);
-  pthread_setspecific(_tls_key, NULL);
-}
-
-struct TlsData *tls_get_val()
-{
-  void *val;
-
-  if (!_initialized) {
-    return NULL;
-  }
-
-  val  = pthread_getspecific(_tls_key);
-
-  if (!val) {
-    int ret;
-    val = malloc(sizeof(struct TlsData));
-    memset(val, 0, sizeof(struct TlsData));
-    ret = pthread_setspecific(_tls_key, val);
-
-    if (ret)
-      return NULL;
-  }
-
-  return (struct TlsData *)val;
-}
-
-int tls_init()
-{
-  int ret = 0;
-
-  if (!_initialized) {
-    ret = pthread_key_create(&_tls_key, _tls_destructor);
-    _initialized = 1;
-  }
-  return ret; 
-}
-
-void tls_finalize()
-{
-  if (_initialized)
-    pthread_key_delete(_tls_key);
-}
diff --git a/src/common/tls.h b/src/common/tls.h
deleted file mode 100644 (file)
index 3293932..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef CEPH_TLS_H
-#define CEPH_TLS_H
-
-struct TlsData {
-  int disable_assert;
-};
-
-
-struct TlsData *tls_get_val();
-int tls_init();
-void tls_finalize();
-
-
-#endif