Преглед на файлове

HPCC-13185 Assert connection before setting timeout

Signed-off-by: James Noss <james.noss@lexisnexis.com>
James Noss преди 10 години
родител
ревизия
aac21b2e49
променени са 3 файла, в които са добавени 12 реда и са изтрити 2 реда
  1. 1 1
      plugins/redis/redis.cpp
  2. 3 0
      testing/regress/ecl/key/redissynctest.xml
  3. 8 1
      testing/regress/ecl/redissynctest.ecl

+ 1 - 1
plugins/redis/redis.cpp

@@ -192,8 +192,8 @@ void Connection::connect(ICodeContext * ctx, unsigned __int64 _database, const c
 {
     struct timeval to = { timeout/1000, (timeout%1000)*1000 };
     context = redisConnectWithTimeout(ip.str(), port, to);
-    redisSetTimeout(context, to);
     assertConnection();
+    redisSetTimeout(context, to);
 
     //The following is the dissemination of the two methods authenticate(ctx, password) & selectDB(ctx, _database)
     //such that they may be pipelined to save an extra round trip to the server and back.

+ 3 - 0
testing/regress/ecl/key/redissynctest.xml

@@ -94,3 +94,6 @@
 <Dataset name='Result 32'>
  <Row><value>Redis Plugin: ERROR - the requested key &apos;authTest1&apos; does not exist on database 0</value></Row>
 </Dataset>
+<Dataset name='Result 33'>
+ <Row><value>Redis Plugin: Connection failed - Connection refused for 127.0.0.1:9999</value></Row>
+</Dataset>

+ 8 - 1
testing/regress/ecl/redissynctest.ecl

@@ -168,6 +168,13 @@ SEQUENTIAL(
     myRedis.FlushDB();
     OUTPUT(CATCH(ds2, ONFAIL(TRANSFORM({ STRING value }, SELF.value := FAILMESSAGE))));
     );
-    
+
+myRedis5 := RedisServer('--SERVER=127.0.0.1:9999');
+ds3 := DATASET(NOFOLD(1), TRANSFORM({string value}, SELF.value := myRedis5.GetString('connectTest' + (string)COUNTER)));
+SEQUENTIAL(
+    myRedis.FlushDB();
+    OUTPUT(CATCH(ds3, ONFAIL(TRANSFORM({ STRING value }, SELF.value := FAILMESSAGE))));
+    );
+
 myRedis.FlushDB();
 myRedis2.FlushDB();