File tree Expand file tree Collapse file tree 1 file changed +15
-14
lines changed Expand file tree Collapse file tree 1 file changed +15
-14
lines changed Original file line number Diff line number Diff line change @@ -718,31 +718,32 @@ shm_mq_receive_with_timeout(shm_mq_handle *mqh,
718
718
void * * datap ,
719
719
long timeout )
720
720
{
721
-
722
- #ifdef HAVE_INT64_TIMESTAMP
723
- #define GetNowFloat () ((float8) GetCurrentTimestamp() / 1000.0)
724
- #else
725
- #define GetNowFloat () 1000.0 * GetCurrentTimestamp()
726
- #endif
727
-
728
- float8 endtime = GetNowFloat () + timeout ;
729
- int rc = 0 ;
721
+ int rc = 0 ;
722
+ long delay = timeout ;
730
723
731
724
for (;;)
732
725
{
733
- long delay ;
726
+ instr_time start_time ;
727
+ instr_time cur_time ;
734
728
shm_mq_result mq_receive_result ;
735
729
736
- mq_receive_result = shm_mq_receive (mqh , nbytesp , datap , true);
730
+ elog (INFO , "%ld" , delay );
731
+
732
+ INSTR_TIME_SET_CURRENT (start_time );
737
733
734
+ mq_receive_result = shm_mq_receive (mqh , nbytesp , datap , true);
738
735
if (mq_receive_result != SHM_MQ_WOULD_BLOCK )
739
736
return mq_receive_result ;
740
-
741
- if (rc & WL_TIMEOUT )
737
+ if (rc & WL_TIMEOUT || delay <= 0 )
742
738
return SHM_MQ_WOULD_BLOCK ;
743
739
744
- delay = (long ) (endtime - GetNowFloat ());
745
740
rc = WaitLatch (MyLatch , WL_LATCH_SET | WL_TIMEOUT , delay );
741
+
742
+ INSTR_TIME_SET_CURRENT (cur_time );
743
+ INSTR_TIME_SUBTRACT (cur_time , start_time );
744
+
745
+ delay = timeout - (long ) INSTR_TIME_GET_MILLISEC (cur_time );
746
+
746
747
CHECK_FOR_INTERRUPTS ();
747
748
ResetLatch (MyLatch );
748
749
}
You can’t perform that action at this time.
0 commit comments