Jelajahi Sumber

更新 src/tencent_cos.cpp

1585346868 8 bulan lalu
induk
melakukan
6e72d68166
1 mengubah file dengan 8 tambahan dan 3 penghapusan
  1. 8 3
      src/tencent_cos.cpp

+ 8 - 3
src/tencent_cos.cpp

@@ -3,6 +3,7 @@
 #include "cos_api.h"
 #include "cos_http_io.h"
 #include "cos_log.h"
+static int inited = 0;
 extern "C" {
 #ifdef _WIN32
     DLL_EXPORT
@@ -17,14 +18,18 @@ extern "C" {
 
 module::tencent_cos::tencent_cos()
 {
-    if (cos_http_io_initialize(NULL, 0) != COSE_OK) {
-        printf("COS HTTP INIT FAILED");
+    if(inited == 0){
+        if (cos_http_io_initialize(NULL, 0) != COSE_OK) {
+            printf("COS HTTP INIT FAILED");
+            return;
+        }
+        inited = 1;
     }
 }
 
 module::tencent_cos::~tencent_cos()
 {
-    cos_http_io_deinitialize();
+    // cos_http_io_deinitialize();
 }
 
 std::string module::tencent_cos::upfile(const std::string& appid,const std::string& endpoint,const std::string& access_key_id,const std::string& access_key_secret,const std::string& bucket_name,const std::string& object_name,const std::string& filepath)