@@ -332,7 +332,6 @@ bool raftable_set(const char *key, const char *value, size_t vallen, int timeout
332
332
size_t size = sizeof (RaftableUpdate );
333
333
size_t keylen = 0 ;
334
334
timeout_t timeout ;
335
- timeout_start (& timeout ,timeout_ms );
336
335
337
336
Assert (wcfg .id >=0 );
338
337
@@ -352,17 +351,37 @@ bool raftable_set(const char *key, const char *value, size_t vallen, int timeout
352
351
memcpy (f -> data ,key ,keylen );
353
352
memcpy (f -> data + keylen ,value ,vallen );
354
353
355
- TIMEOUT_LOOP_START ( & timeout );
354
+ if ( timeout_ms < 0 )
356
355
{
357
- if ( try_sending_update ( ru , size , & timeout ) )
356
+ while (true )
358
357
{
359
- pfree (ru );
360
- return true;
358
+ timeout_start (& timeout ,100 );
359
+
360
+ if (try_sending_update (ru ,size ,& timeout ))
361
+ {
362
+ pfree (ru );
363
+ return true;
364
+ }
365
+ else
366
+ disconnect_leader ();
367
+ }
368
+ }
369
+ else
370
+ {
371
+ timeout_start (& timeout ,timeout_ms );
372
+
373
+ TIMEOUT_LOOP_START (& timeout );
374
+ {
375
+ if (try_sending_update (ru ,size ,& timeout ))
376
+ {
377
+ pfree (ru );
378
+ return true;
379
+ }
380
+ else
381
+ disconnect_leader ();
361
382
}
362
- else
363
- disconnect_leader ();
383
+ TIMEOUT_LOOP_END (& timeout );
364
384
}
365
- TIMEOUT_LOOP_END (& timeout );
366
385
367
386
pfree (ru );
368
387
elog (WARNING ,"failed to set raftable value after %d ms" ,timeout_elapsed_ms (& timeout ));