Skip to content

Commit

Permalink
Make projection context ref counting thread safe (MapServer#7079)
Browse files Browse the repository at this point in the history
  • Loading branch information
szekerest committed Jun 16, 2024
1 parent d8bc719 commit 9d18505
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions mapproject.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ struct projectionContext
{
PJ_CONTEXT* proj_ctx;
unsigned ms_proj_data_change_counter;
int ref_count;
int refcount;
pjCacheEntry pj_cache[PJ_CACHE_ENTRY_SIZE];
int pj_cache_size;
};
Expand Down Expand Up @@ -381,7 +381,7 @@ projectionContext* msProjectionContextCreate(void)
msFree(ctx);
return NULL;
}
ctx->ref_count = 1;
MS_REFCNT_INIT(ctx);
proj_context_use_proj4_init_rules(ctx->proj_ctx, TRUE);
proj_log_func (ctx->proj_ctx, NULL, msProjErrorLogger);
return ctx;
Expand All @@ -395,8 +395,7 @@ void msProjectionContextUnref(projectionContext* ctx)
{
if( !ctx )
return;
--ctx->ref_count;
if( ctx->ref_count == 0 )
if(MS_REFCNT_DECR_IS_ZERO(ctx))
{
int i;
for( i = 0; i < ctx->pj_cache_size; i++ )
Expand Down Expand Up @@ -678,7 +677,7 @@ void msProjectionInheritContextFrom(projectionObj *pDst, const projectionObj* pS
if( pDst->proj_ctx == NULL && pSrc->proj_ctx != NULL)
{
pDst->proj_ctx = pSrc->proj_ctx;
pDst->proj_ctx->ref_count ++;
MS_REFCNT_INCR(pDst->proj_ctx);
}
#else
(void)pDst;
Expand All @@ -696,7 +695,7 @@ void msProjectionSetContext(projectionObj *p, projectionContext* ctx)
if( p->proj_ctx == NULL && ctx != NULL)
{
p->proj_ctx = ctx;
p->proj_ctx->ref_count ++;
MS_REFCNT_INCR(p->proj_ctx);
}
#else
(void)p;
Expand Down

0 comments on commit 9d18505

Please sign in to comment.