Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(447)

Side by Side Diff: printing/backend/print_backend_cups.cc

Issue 9290036: Linux: Try several different paths to the GnuTls library when trying to dynamically load and call g… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: add error messages Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "printing/backend/print_backend.h" 5 #include "printing/backend/print_backend.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #include <dlfcn.h> 9 #include <dlfcn.h>
10 #include <errno.h> 10 #include <errno.h>
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 // gnutls_global_init(). 52 // gnutls_global_init().
53 53
54 class GcryptInitializer { 54 class GcryptInitializer {
55 public: 55 public:
56 GcryptInitializer() { 56 GcryptInitializer() {
57 Init(); 57 Init();
58 } 58 }
59 59
60 private: 60 private:
61 void Init() { 61 void Init() {
62 const char* kGnuTlsFiles[] = {
63 "libgnutls.so.28",
64 "libgnutls.so.26",
65 "libgnutls.so",
66 };
62 gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); 67 gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
63 const char* kGnuTlsFile = "libgnutls.so"; 68 for (size_t i = 0; i < arraysize(kGnuTlsFiles); ++i) {
64 void* gnutls_lib = dlopen(kGnuTlsFile, RTLD_NOW); 69 void* gnutls_lib = dlopen(kGnuTlsFiles[i], RTLD_NOW);
65 if (!gnutls_lib) { 70 if (!gnutls_lib) {
66 LOG(ERROR) << "Cannot load " << kGnuTlsFile; 71 VLOG(1) << "Cannot load " << kGnuTlsFiles[i];
72 continue;
73 }
74 const char* kGnuTlsInitFuncName = "gnutls_global_init";
75 int (*pgnutls_global_init)(void) = reinterpret_cast<int(*)()>(
76 dlsym(gnutls_lib, kGnuTlsInitFuncName));
77 if (!pgnutls_global_init) {
78 VLOG(1) << "Could not find " << kGnuTlsInitFuncName
79 << " in " << kGnuTlsFiles[i];
80 continue;
81 }
82 if ((*pgnutls_global_init)() != 0)
83 LOG(ERROR) << "gnutls_global_init() failed";
67 return; 84 return;
68 } 85 }
69 const char* kGnuTlsInitFuncName = "gnutls_global_init"; 86 LOG(ERROR) << "Cannot find libgnutls";
70 int (*pgnutls_global_init)(void) = reinterpret_cast<int(*)()>(
71 dlsym(gnutls_lib, kGnuTlsInitFuncName));
72 if (!pgnutls_global_init) {
73 LOG(ERROR) << "Could not find " << kGnuTlsInitFuncName
74 << " in " << kGnuTlsFile;
75 return;
76 }
77 if ((*pgnutls_global_init)() != 0)
78 LOG(ERROR) << "Gnutls initialization failed";
79 } 87 }
80 }; 88 };
81 89
82 static base::LazyInstance<GcryptInitializer> g_gcrypt_initializer = 90 static base::LazyInstance<GcryptInitializer> g_gcrypt_initializer =
83 LAZY_INSTANCE_INITIALIZER; 91 LAZY_INSTANCE_INITIALIZER;
84 92
85 } // namespace 93 } // namespace
86 #endif // !defined(OS_MACOSX) 94 #endif // !defined(OS_MACOSX)
87 95
88 namespace printing { 96 namespace printing {
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 << ", HTTP error: " << http_error; 310 << ", HTTP error: " << http_error;
303 file_util::Delete(ppd_path, false); 311 file_util::Delete(ppd_path, false);
304 ppd_path.clear(); 312 ppd_path.clear();
305 } 313 }
306 } 314 }
307 } 315 }
308 return ppd_path; 316 return ppd_path;
309 } 317 }
310 318
311 } // namespace printing 319 } // namespace printing
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698