Commit 75174823 authored by thestig@chromium.org's avatar thestig@chromium.org

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
parent 9af082bc
......@@ -10,7 +10,6 @@ libfontconfig1 (>= 2.8.0)
libfreetype6 (>= 2.3.9)
libgcc1 (>= 1:4.1.1)
libgconf-2-4 (>= 2.31.1)
libgcrypt11 (>= 1.4.5)
libgdk-pixbuf2.0-0 (>= 2.22.0)
libglib2.0-0 (>= 2.26.0)
libgtk2.0-0 (>= 2.24.0)
......
......@@ -32,7 +32,6 @@ libgcc_s.so.1(GCC_3.4)
libgcc_s.so.1(GCC_4.0.0)
libgcc_s.so.1(GLIBC_2.0)
libgconf-2.so.4
libgcrypt.so.11
libgdk_pixbuf-2.0.so.0
libgdk-x11-2.0.so.0
libgio-2.0.so.0
......
......@@ -26,7 +26,6 @@ libgcc_s.so.1()(64bit)
libgcc_s.so.1(GCC_3.4)(64bit)
libgcc_s.so.1(GCC_4.0.0)(64bit)
libgconf-2.so.4()(64bit)
libgcrypt.so.11()(64bit)
libgdk_pixbuf-2.0.so.0()(64bit)
libgdk-x11-2.0.so.0()(64bit)
libgio-2.0.so.0()(64bit)
......
......@@ -16,6 +16,7 @@ KEYRING_FILE=/usr/share/keyrings/ubuntu-archive-keyring.gpg
# Sysroot packages: these are the packages needed to build chrome.
# NOTE: When DEBIAN_PACKAGES is modified, the packagelist files must be updated
# by running this script in GeneratePackageList mode.
# TODO(thestig) Remove libgcrypt11* the next time a package gets added.
DEBIAN_PACKAGES="\
comerr-dev \
gcc-4.8 \
......
......@@ -13,6 +13,7 @@ KEYRING_FILE=/usr/share/keyrings/debian-archive-keyring.gpg
# Sysroot packages: these are the packages needed to build chrome.
# NOTE: When DEBIAN_PACKAGES is modified, the packagelist files must be updated
# by running this script in GeneratePackageList mode.
# TODO(thestig) Remove libgcrypt11* the next time a package gets added.
DEBIAN_PACKAGES="\
comerr-dev \
gcc-4.6 \
......
......@@ -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) {
......
......@@ -281,7 +281,7 @@
],
},
}],
[ 'os_bsd==1', {
['os_bsd==1', {
'cflags': [
'<!@(python cups_config_helper.py --cflags)',
],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment