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

Commit49da956

Browse files
Marina Polyakovaza-arthur
Marina Polyakova
authored andcommitted
PGPRO-2033: a try to fix the use of dispell_reset in shared_ispell on Windows
The shared_ispell dictionary is loaded into memory if the timestamp of its lastlookup is less than the timestamp of the reset of the shared dictionary memory.These timestamps used the function gettimeofday() which is not for Win32 highprecision timing purposes. Therefore sometimes the timestamp of the lastdictinary lookup and the timestamp of the reset of the shared dictionary memoryare equal and the function ts_lexize returns NULL (from buildfarm). To avoidthis use the structure instr_time and its macros/functions with portablehigh-precision interval timing for the same purpose.
1 parente6d908d commit49da956

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

‎src/shared_ispell.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ ispell_shmem_startup()
194194
segment_info->available=max_ispell_mem_size()-
195195
(int) (segment_info->firstfree-segment);
196196

197-
segment_info->lastReset=GetCurrentTimestamp();
197+
INSTR_TIME_SET_CURRENT(segment_info->lastReset);
198198
}
199199

200200
LWLockRelease(AddinShmemInitLock);
@@ -409,7 +409,7 @@ init_shared_dict(DictInfo *info, MemoryContext infoCntx,
409409

410410
info->shdict=shdict;
411411
info->shstop=shstop;
412-
info->lookup=GetCurrentTimestamp();
412+
INSTR_TIME_SET_CURRENT(info->lookup);
413413

414414
memcpy(info->dictFile,dictFile,strlen(dictFile)+1);
415415
memcpy(info->affixFile,affFile,strlen(affFile)+1);
@@ -444,7 +444,7 @@ dispell_reset(PG_FUNCTION_ARGS)
444444

445445
segment_info->shdict=NULL;
446446
segment_info->shstop=NULL;
447-
segment_info->lastReset=GetCurrentTimestamp();
447+
INSTR_TIME_SET_CURRENT(segment_info->lastReset);
448448
segment_info->firstfree= ((char*)segment_info)+MAXALIGN(sizeof(SegmentInfo));
449449
segment_info->available=max_ispell_mem_size()-
450450
(int) (segment_info->firstfree- (char*)segment_info);
@@ -612,7 +612,8 @@ dispell_lexize(PG_FUNCTION_ARGS)
612612
LWLockAcquire(segment_info->lock,LW_SHARED);
613613

614614
/* do we need to reinit the dictionary? was the dict reset since the lookup */
615-
if (timestamp_cmp_internal(info->lookup,segment_info->lastReset)<0)
615+
if (INSTR_TIME_GET_MICROSEC(info->lookup)<
616+
INSTR_TIME_GET_MICROSEC(segment_info->lastReset))
616617
{
617618
DictInfosaveInfo=*info;
618619

‎src/shared_ispell.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ typedef struct SegmentInfo
4444
LWLockIdlock;
4545
char*firstfree;/* first free address (always maxaligned) */
4646
size_tavailable;/* free space remaining at firstfree */
47-
TimestamplastReset;/* last reset of the dictionary */
47+
instr_timelastReset;/* last reset of the dictionary */
4848

4949
/* the shared segment (info and data) */
5050
SharedIspellDict*shdict;
@@ -54,7 +54,7 @@ typedef struct SegmentInfo
5454
/* used to keep track of dictionary in each backend */
5555
typedefstructDictInfo
5656
{
57-
Timestamplookup;
57+
instr_timelookup;
5858

5959
chardictFile[MAXLEN];
6060
charaffixFile[MAXLEN];

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp