| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 namespace { | 36 namespace { |
| 37 | 37 |
| 38 // Init GCrypt library (needed for CUPS) using pthreads. | 38 // Init GCrypt library (needed for CUPS) using pthreads. |
| 39 // There exists a bug in CUPS library, where it crashed with: "ath.c:184: | 39 // There exists a bug in CUPS library, where it crashed with: "ath.c:184: |
| 40 // _gcry_ath_mutex_lock: Assertion `*lock == ((ath_mutex_t) 0)' failed." | 40 // _gcry_ath_mutex_lock: Assertion `*lock == ((ath_mutex_t) 0)' failed." |
| 41 // It happened when multiple threads tried printing simultaneously. | 41 // It happened when multiple threads tried printing simultaneously. |
| 42 // Google search for 'gnutls thread safety' provided a solution that | 42 // Google search for 'gnutls thread safety' provided a solution that |
| 43 // initialized gcrypt and gnutls. | 43 // initialized gcrypt and gnutls. |
| 44 | 44 |
| 45 // TODO(phajdan.jr): Remove this after https://bugs.g10code.com/gnupg/issue1197 |
| 46 // gets fixed on all Linux distros we support (i.e. when they ship libgcrypt |
| 47 // with the fix). |
| 48 |
| 45 // Initially, we linked with -lgnutls and simply called gnutls_global_init(), | 49 // Initially, we linked with -lgnutls and simply called gnutls_global_init(), |
| 46 // but this did not work well since we build one binary on Ubuntu Hardy and | 50 // but this did not work well since we build one binary on Ubuntu Hardy and |
| 47 // expect it to run on many Linux distros. (See http://crbug.com/46954) | 51 // expect it to run on many Linux distros. (See http://crbug.com/46954) |
| 48 // So instead we use dlopen() and dlsym() to dynamically load and call | 52 // So instead we use dlopen() and dlsym() to dynamically load and call |
| 49 // gnutls_global_init(). | 53 // gnutls_global_init(). |
| 50 | 54 |
| 51 class GcryptInitializer { | 55 class GcryptInitializer { |
| 52 public: | 56 public: |
| 53 GcryptInitializer() { | 57 GcryptInitializer() { |
| 54 Init(); | 58 Init(); |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 << ", HTTP error: " << http_error; | 370 << ", HTTP error: " << http_error; |
| 367 file_util::Delete(ppd_path, false); | 371 file_util::Delete(ppd_path, false); |
| 368 ppd_path.clear(); | 372 ppd_path.clear(); |
| 369 } | 373 } |
| 370 } | 374 } |
| 371 } | 375 } |
| 372 return ppd_path; | 376 return ppd_path; |
| 373 } | 377 } |
| 374 | 378 |
| 375 } // namespace printing | 379 } // namespace printing |
| OLD | NEW |