Fix snd/recv when number is higher then domain of value.
authorBrian Aker <brian@tangent.org>
Sun, 12 Aug 2012 17:34:01 +0000 (13:34 -0400)
committerBrian Aker <brian@tangent.org>
Sun, 12 Aug 2012 17:34:01 +0000 (13:34 -0400)
libmemcached-1.0/struct/memcached.h
libmemcached/connect.cc
libmemcached/csl/context.h
tests/libmemcached-1.0/mem_functions.cc

index 63b07a00e80a8b3b6219524515e6ef756a51ac94..624887b74daee55bbedc839ac81b3540d176dc4e 100644 (file)
@@ -45,7 +45,7 @@ struct memcached_st {
     bool is_purging:1;
     bool is_processing_input:1;
     bool is_time_for_rebuild:1;
-    bool not_used:1;
+    bool is_parsing:1;
   } state;
 
   struct {
index 1ace3fd8c72b47a39f1dc683d98df5375c5fdbe4..dfe69c0b3d51424172360e6ce365e4e7be1fdf0a 100644 (file)
@@ -250,27 +250,26 @@ static void set_socket_options(org::libmemcached::Instance* server)
   }
 
 #ifdef HAVE_SNDTIMEO
-  if (server->root->snd_timeout)
+  if (server->root->snd_timeout > 0)
   {
     struct timeval waittime;
 
-    waittime.tv_sec= 0;
-    waittime.tv_usec= server->root->snd_timeout;
+    waittime.tv_sec= server->root->snd_timeout / 1000000;
+    waittime.tv_usec= server->root->snd_timeout % 1000000;
 
     int error= setsockopt(server->fd, SOL_SOCKET, SO_SNDTIMEO,
-                      &waittime, (socklen_t)sizeof(struct timeval));
-    (void)(error);
+                          &waittime, (socklen_t)sizeof(struct timeval));
     assert(error == 0);
   }
 #endif
 
 #ifdef HAVE_RCVTIMEO
-  if (server->root->rcv_timeout)
+  if (server->root->rcv_timeout > 0)
   {
     struct timeval waittime;
 
-    waittime.tv_sec= 0;
-    waittime.tv_usec= server->root->rcv_timeout;
+    waittime.tv_sec= server->root->rcv_timeout / 1000000;
+    waittime.tv_usec= server->root->rcv_timeout % 1000000;
 
     int error= setsockopt(server->fd, SOL_SOCKET, SO_RCVTIMEO,
                           &waittime, (socklen_t)sizeof(struct timeval));
@@ -737,6 +736,11 @@ static memcached_return_t _memcached_connect(org::libmemcached::Instance* server
 
 memcached_return_t memcached_connect_try(org::libmemcached::Instance* server)
 {
+  if (server and server->root and server->root->state.is_parsing)
+  {
+    return MEMCACHED_SUCCESS;
+  }
+
   return _memcached_connect(server, false);
 }
 
index 77fac219bdd79ed2ecca1fd634af9e76c5ca5935..12e028ddcaeac95c74c33073e273d3957a1cff50 100644 (file)
@@ -61,6 +61,8 @@ public:
     memc= memc_arg;
     init_scanner();
     rc= MEMCACHED_SUCCESS;
+
+    memc->state.is_parsing= true;
   }
 
   bool end()
@@ -106,6 +108,7 @@ public:
   ~Context()
   {
     destroy_scanner();
+    memc->state.is_parsing= false;
   }
 
   yytokentype previous_token;
index 07603cb4219c4f60bacf8b29c3c0431eb6994bd8..3b1701e8315da782714a59810861b44c7720f3b2 100644 (file)
@@ -4480,6 +4480,7 @@ test_return_t regression_1021819_TEST(memcached_st *original)
   test_true(memc);
 
   test_compare(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SND_TIMEOUT, 2000000), MEMCACHED_SUCCESS);
+  test_compare(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_RCV_TIMEOUT, 3000000), MEMCACHED_SUCCESS);
 
   memcached_return_t rc;