Skip to content

Commit 981d8d2

Browse files
committed
Make projection context ref counting thread safe again
1 parent 383a7cc commit 981d8d2

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

mapproject.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ struct projectionContext
8282
void* thread_id;
8383
PJ_CONTEXT* proj_ctx;
8484
unsigned ms_proj_data_change_counter;
85-
int ref_count;
85+
int refcount;
8686
pjCacheEntry pj_cache[PJ_CACHE_ENTRY_SIZE];
8787
int pj_cache_size;
8888
};
@@ -383,7 +383,7 @@ projectionContext* msProjectionContextCreate(void)
383383
msFree(ctx);
384384
return NULL;
385385
}
386-
ctx->ref_count = 1;
386+
MS_REFCNT_INIT(ctx);
387387
proj_context_use_proj4_init_rules(ctx->proj_ctx, TRUE);
388388
proj_log_func (ctx->proj_ctx, NULL, msProjErrorLogger);
389389
return ctx;
@@ -397,8 +397,7 @@ void msProjectionContextUnref(projectionContext* ctx)
397397
{
398398
if( !ctx )
399399
return;
400-
--ctx->ref_count;
401-
if (ctx->ref_count == 0)
400+
if (MS_REFCNT_DECR_IS_ZERO(ctx))
402401
{
403402
int i;
404403
for( i = 0; i < ctx->pj_cache_size; i++ )
@@ -704,7 +703,7 @@ void msProjectionInheritContextFrom(projectionObj *pDst, const projectionObj* pS
704703
{
705704
if (pSrc->proj_ctx->thread_id == msGetThreadId()) {
706705
pDst->proj_ctx = pSrc->proj_ctx;
707-
pDst->proj_ctx->ref_count++;
706+
MS_REFCNT_INCR(pDst->proj_ctx);
708707
} else {
709708
pDst->proj_ctx = msProjectionContextClone(pSrc->proj_ctx);
710709
}
@@ -725,7 +724,7 @@ void msProjectionSetContext(projectionObj *p, projectionContext* ctx)
725724
if( p->proj_ctx == NULL && ctx != NULL)
726725
{
727726
p->proj_ctx = ctx;
728-
p->proj_ctx->ref_count++;
727+
MS_REFCNT_INCR(p->proj_ctx);
729728
}
730729
#else
731730
(void)p;
@@ -2993,7 +2992,7 @@ projectionContext* msProjectionContextGetFromPool()
29932992
{
29942993
LinkedListOfProjContext* next = headOfLinkedListOfProjContext->next;
29952994
context = headOfLinkedListOfProjContext->context;
2996-
context->thread_id = msGetThreadId();
2995+
context->thread_id = msGetThreadId();
29972996
msFree(headOfLinkedListOfProjContext);
29982997
headOfLinkedListOfProjContext = next;
29992998
}

0 commit comments

Comments
 (0)