diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-20 04:13:48 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-20 04:13:48 +0000 |
commit | 75174823cfef2a19897a3f33b4888fc340ac2860 (patch) | |
tree | 115a78a55ea089976f7c202962cb23828c3fe318 /printing/backend | |
parent | 9af082bc2d185af96c7d361b5d649f41a332e73e (diff) | |
download | chromium_src-75174823cfef2a19897a3f33b4888fc340ac2860.zip chromium_src-75174823cfef2a19897a3f33b4888fc340ac2860.tar.gz chromium_src-75174823cfef2a19897a3f33b4888fc340ac2860.tar.bz2 |
Linux: Remove gcrypt initialization workaround.
BUG=369973
TEST=ctrl + p does not crash.
Review URL: https://codereview.chromium.org/270553003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@271563 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing/backend')
-rw-r--r-- | printing/backend/print_backend_cups.cc | 79 |
1 files changed, 0 insertions, 79 deletions
diff --git a/printing/backend/print_backend_cups.cc b/printing/backend/print_backend_cups.cc index bf7141e..e1ddf84 100644 --- a/printing/backend/print_backend_cups.cc +++ b/printing/backend/print_backend_cups.cc @@ -10,10 +10,6 @@ #include <errno.h> #include <pthread.h> -#if !defined(OS_MACOSX) -#include <gcrypt.h> -#endif - #include "base/debug/leak_annotations.h" #include "base/file_util.h" #include "base/lazy_instance.h" @@ -25,76 +21,6 @@ #include "printing/backend/print_backend_consts.h" #include "url/gurl.h" -#if !defined(OS_MACOSX) -GCRY_THREAD_OPTION_PTHREAD_IMPL; - -namespace { - -// Init GCrypt library (needed for CUPS) using pthreads. -// There exists a bug in CUPS library, where it crashed with: "ath.c:184: -// _gcry_ath_mutex_lock: Assertion `*lock == ((ath_mutex_t) 0)' failed." -// It happened when multiple threads tried printing simultaneously. -// Google search for 'gnutls thread safety' provided a solution that -// initialized gcrypt and gnutls. - -// TODO(phajdan.jr): Remove this after https://bugs.g10code.com/gnupg/issue1197 -// gets fixed on all Linux distros we support (i.e. when they ship libgcrypt -// with the fix). - -// Initially, we linked with -lgnutls and simply called gnutls_global_init(), -// but this did not work well since we build one binary on Ubuntu Hardy and -// expect it to run on many Linux distros. (See http://crbug.com/46954) -// So instead we use dlopen() and dlsym() to dynamically load and call -// gnutls_global_init(). - -class GcryptInitializer { - public: - GcryptInitializer() { - Init(); - } - - private: - void Init() { - const char* kGnuTlsFiles[] = { - "libgnutls.so.28", - "libgnutls.so.26", - "libgnutls.so", - }; - gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); - for (size_t i = 0; i < arraysize(kGnuTlsFiles); ++i) { - void* gnutls_lib = dlopen(kGnuTlsFiles[i], RTLD_NOW); - if (!gnutls_lib) { - VLOG(1) << "Cannot load " << kGnuTlsFiles[i]; - continue; - } - const char* kGnuTlsInitFuncName = "gnutls_global_init"; - int (*pgnutls_global_init)(void) = reinterpret_cast<int(*)()>( - dlsym(gnutls_lib, kGnuTlsInitFuncName)); - if (!pgnutls_global_init) { - VLOG(1) << "Could not find " << kGnuTlsInitFuncName - << " in " << kGnuTlsFiles[i]; - continue; - } - { - // GnuTLS has a genuine small memory leak that is easier to annotate - // than suppress. See http://crbug.com/176888#c7 - // TODO(earthdok): remove this once the leak is fixed. - ANNOTATE_SCOPED_MEMORY_LEAK; - if ((*pgnutls_global_init)() != 0) - LOG(ERROR) << "gnutls_global_init() failed"; - } - return; - } - LOG(ERROR) << "Cannot find libgnutls"; - } -}; - -base::LazyInstance<GcryptInitializer> g_gcrypt_initializer = - LAZY_INSTANCE_INITIALIZER; - -} // namespace -#endif // !defined(OS_MACOSX) - namespace printing { static const char kCUPSPrinterInfoOpt[] = "printer-info"; @@ -296,11 +222,6 @@ bool PrintBackendCUPS::IsValidPrinter(const std::string& printer_name) { scoped_refptr<PrintBackend> PrintBackend::CreateInstance( const base::DictionaryValue* print_backend_settings) { -#if !defined(OS_MACOSX) - // Initialize gcrypt library. - g_gcrypt_initializer.Get(); -#endif - std::string print_server_url_str, cups_blocking; int encryption = HTTP_ENCRYPT_NEVER; if (print_backend_settings) { |