Skip to content

Commit

Permalink
utilize difftime() to subtract time to live
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristy committed Oct 14, 2023
1 parent 16e7c9f commit 5b91181
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion magick/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -1854,7 +1854,7 @@ static Cache GetImagePixelCache(Image *image,const MagickBooleanType clone,
cpu_throttle = MagickResourceInfinity,
cycles = 0;

if (((double) image->timestamp+image->ttl) < (double) GetMagickTime())
if (difftime(GetMagickTime(),image->timestamp) > (double) image->ttl)
{
cache_info=(CacheInfo *) image->cache;
if (cache_info->file != -1)
Expand Down
6 changes: 3 additions & 3 deletions magick/fx.c
Original file line number Diff line number Diff line change
Expand Up @@ -2163,7 +2163,7 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,const ChannelType channel,
FxParseConditional(subexpression,',',p,q);
for (alpha=0.0; ; )
{
if (((double) fx_info->images->timestamp+fx_info->images->ttl) < (double) GetMagickTime())
if (difftime(GetMagickTime(),fx_info->images->timestamp) > (double) fx_info->images->ttl)
(void) ThrowMagickException(exception,GetMagickModule(),
ResourceLimitFatalError,"TimeLimitExceeded","`%s'",
fx_info->images->filename);
Expand Down Expand Up @@ -2238,7 +2238,7 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,const ChannelType channel,
FxParseConditional(subexpression,',',p,q);
for (alpha=0.0; ; )
{
if (((double) fx_info->images->timestamp+fx_info->images->ttl) < (double) GetMagickTime())
if (difftime(GetMagickTime(),fx_info->images->timestamp) > (double) fx_info->images->ttl)
(void) ThrowMagickException(exception,GetMagickModule(),
ResourceLimitFatalError,"TimeLimitExceeded","`%s'",
fx_info->images->filename);
Expand Down Expand Up @@ -2620,7 +2620,7 @@ static double FxEvaluateSubexpression(FxInfo *fx_info,const ChannelType channel,
FxParseConditional(subexpression,',',p,q);
for (alpha=0.0; ; )
{
if (((double) fx_info->images->timestamp+fx_info->images->ttl) < (double) GetMagickTime())
if (difftime(GetMagickTime(),fx_info->images->timestamp) > (double) fx_info->images->ttl)
(void) ThrowMagickException(exception,GetMagickModule(),
ResourceLimitFatalError,"TimeLimitExceeded","`%s'",
fx_info->images->filename);
Expand Down
8 changes: 4 additions & 4 deletions magick/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ MagickExport double GetElapsedTime(TimerInfo *time_info)
MagickExport time_t GetMagickTime(void)
{
static time_t
constant_magick_time = (time_t) 0;
magick_epoch = (time_t) 0;

static MagickBooleanType
epoch_initialized = MagickFalse;
Expand All @@ -349,11 +349,11 @@ MagickExport time_t GetMagickTime(void)
epoch=(time_t) CastDoubleToLong(StringToDouble(source_date_epoch,
(char **) NULL));
if ((epoch > 0) && (epoch <= time((time_t *) NULL)))
constant_magick_time=epoch;
magick_epoch=epoch;
}
}
if (constant_magick_time != 0)
return(constant_magick_time);
if (magick_epoch != 0)
return(magick_epoch);
return(time((time_t *) NULL));
}

Expand Down

0 comments on commit 5b91181

Please sign in to comment.