소스 검색

HPCC-18237 Couchbase Plugin: Address Coverity concerns

Signed-off-by: Dan S. Camper <dan.camper@lexisnexisrisk.com>
Dan S. Camper 7 년 전
부모
커밋
eb8ac5dbae
2개의 변경된 파일5개의 추가작업 그리고 7개의 파일을 삭제
  1. 2 6
      plugins/couchbase/couchbaseembed.cpp
  2. 3 1
      plugins/couchbase/couchbaseembed.hpp

+ 2 - 6
plugins/couchbase/couchbaseembed.cpp

@@ -546,7 +546,8 @@ namespace couchbaseembed
                     // use a small loop to retry connections if necessary
                     unsigned int connectAttempt = 0;
                     unsigned int MAX_ATTEMPTS = 10;
-                    useconds_t SLEEP_TIME = 100 + (rand() % 200);
+                    // coverity[DC.WEAK_CRYPTO]
+                    useconds_t SLEEP_TIME = 100 + (rand() % 200); // Add jitter to sleep time
 
                     while (true)
                     {
@@ -611,11 +612,6 @@ namespace couchbaseembed
                     }
                 }
 
-                if (!connectionObjPtr)
-                {
-                    failx("Couchbase: Unable to create connection: %s", connectionString.str());
-                }
-
                 return connectionObjPtr;
             }
 

+ 3 - 1
plugins/couchbase/couchbaseembed.hpp

@@ -189,14 +189,16 @@ namespace couchbaseembed
         CouchbaseConnection(bool useSSL, const char * host, unsigned port, const char * bucketname, const char * password, const char * connOptions)
         {
             StringBuffer connectionString;
-            
+
             makeConnectionString(useSSL, host, port, bucketname, connOptions, connectionString);
             m_pCouchbaseClient = new Couchbase::Client(connectionString.str(), password);
+            timeLastUsed = 0;
         }
 
         CouchbaseConnection(const StringBuffer& connectionString, const char * password)
         {
             m_pCouchbaseClient = new Couchbase::Client(connectionString.str(), password);
+            timeLastUsed = 0;
         }
 
         virtual ~CouchbaseConnection()