浏览代码

Throw exception with error message if gnutls_global_init() failed.

Tatsuhiro Tsujikawa 14 年之前
父节点
当前提交
aa13ff5f51
共有 1 个文件被更改,包括 8 次插入1 次删除
  1. 8 1
      src/Platform.cc

+ 8 - 1
src/Platform.cc

@@ -68,6 +68,7 @@
 
 #include "DlAbortEx.h"
 #include "message.h"
+#include "fmt.h"
 
 namespace aria2 {
 
@@ -103,7 +104,13 @@ bool Platform::setUp()
   SSL_library_init();
 #endif // HAVE_OPENSSL
 #ifdef HAVE_LIBGNUTLS
-  gnutls_global_init();
+  {
+    int r = gnutls_global_init();
+    if(r != GNUTLS_E_SUCCESS) {
+      throw DL_ABORT_EX(fmt("gnutls_global_init() failed, cause:%s",
+                            gnutls_strerror(r)));
+    }
+  }
 #endif // HAVE_LIBGNUTLS
 
 #ifdef CARES_HAVE_ARES_LIBRARY_INIT