Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit829f414

Browse files
author
Maksim Milyutin
committed
Fix shm_mq_receive_with_timeout
1 parentd79e373 commit829f414

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

‎contrib/pg_query_state/pg_query_state.c

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -718,31 +718,32 @@ shm_mq_receive_with_timeout(shm_mq_handle *mqh,
718718
void**datap,
719719
longtimeout)
720720
{
721-
722-
#ifdefHAVE_INT64_TIMESTAMP
723-
#defineGetNowFloat()((float8) GetCurrentTimestamp() / 1000.0)
724-
#else
725-
#defineGetNowFloat()1000.0 * GetCurrentTimestamp()
726-
#endif
727-
728-
float8endtime=GetNowFloat()+timeout;
729-
intrc=0;
721+
intrc=0;
722+
longdelay=timeout;
730723

731724
for (;;)
732725
{
733-
longdelay;
726+
instr_timestart_time;
727+
instr_timecur_time;
734728
shm_mq_resultmq_receive_result;
735729

736-
mq_receive_result=shm_mq_receive(mqh,nbytesp,datap, true);
730+
elog(INFO,"%ld",delay);
731+
732+
INSTR_TIME_SET_CURRENT(start_time);
737733

734+
mq_receive_result=shm_mq_receive(mqh,nbytesp,datap, true);
738735
if (mq_receive_result!=SHM_MQ_WOULD_BLOCK)
739736
returnmq_receive_result;
740-
741-
if (rc&WL_TIMEOUT)
737+
if (rc&WL_TIMEOUT||delay <=0)
742738
returnSHM_MQ_WOULD_BLOCK;
743739

744-
delay= (long) (endtime-GetNowFloat());
745740
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+
746747
CHECK_FOR_INTERRUPTS();
747748
ResetLatch(MyLatch);
748749
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp