Skip to content

Commit adff937

Browse files
author
Brian Pane
committed
Replaced APR_USEC_PER_SEC division with the new apr_time_sec() macro
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@95916 13f79535-47bb-0310-9956-ffa450edef68
1 parent b5101c1 commit adff937

4 files changed

Lines changed: 12 additions & 8 deletions

File tree

modules/metadata/mod_expires.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ static int add_expires(request_rec *r)
423423
apr_time_t base;
424424
apr_time_t additional;
425425
apr_time_t expires;
426+
int additional_sec;
426427
char *timestr;
427428

428429
if (ap_is_HTTP_ERROR(r->status)) /* Don't add Expires headers to errors */
@@ -477,14 +478,16 @@ static int add_expires(request_rec *r)
477478
return DECLINED;
478479
}
479480
base = r->finfo.mtime;
480-
additional = atoi(&code[1]) * APR_USEC_PER_SEC;
481+
additional_sec = atoi(&code[1]);
482+
additional = apr_time_from_sec(additional_sec);
481483
break;
482484
case 'A':
483485
/* there's been some discussion and it's possible that
484486
* 'access time' will be stored in request structure
485487
*/
486488
base = r->request_time;
487-
additional = atoi(&code[1]) * APR_USEC_PER_SEC;
489+
additional_sec = atoi(&code[1]);
490+
additional = apr_time_from_sec(additional_sec);
488491
break;
489492
default:
490493
/* expecting the add_* routines to be case-hardened this
@@ -498,8 +501,7 @@ static int add_expires(request_rec *r)
498501
expires = base + additional;
499502
apr_table_mergen(r->headers_out, "Cache-Control",
500503
apr_psprintf(r->pool, "max-age=%qd",
501-
(expires - r->request_time)
502-
/ APR_USEC_PER_SEC));
504+
apr_time_sec(expires - r->request_time)));
503505
timestr = apr_palloc(r->pool, APR_RFC822_DATE_LEN);
504506
apr_rfc822_date(timestr, expires);
505507
apr_table_setn(r->headers_out, "Expires", timestr);

modules/metadata/mod_mime_magic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1760,7 +1760,7 @@ static void mprint(request_rec *r, union VALUETYPE *p, struct magic *m)
17601760
case DATE:
17611761
case BEDATE:
17621762
case LEDATE:
1763-
apr_ctime(time_str, APR_USEC_PER_SEC * (apr_time_t)*(time_t *)&p->l);
1763+
apr_ctime(time_str, apr_time_from_sec(*(time_t *)&p->l));
17641764
pp = time_str;
17651765
(void) magic_rsl_printf(r, m->desc, pp);
17661766
return;

modules/metadata/mod_unique_id.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ static int unique_id_global_init(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *pt
179179
apr_status_t rv;
180180
char *ipaddrstr;
181181
apr_sockaddr_t *sockaddr;
182+
apr_time_t now;
182183

183184
/*
184185
* Calculate the sizes and offsets in cur_unique_id.
@@ -251,7 +252,8 @@ static int unique_id_global_init(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *pt
251252
* But protecting against it is relatively cheap. We just sleep into the
252253
* next second.
253254
*/
254-
pause = (apr_short_interval_time_t)(1000000 - (apr_time_now() % APR_USEC_PER_SEC));
255+
now = apr_time_now();
256+
pause = (apr_short_interval_time_t)(1000000 - apr_time_usec(now));
255257
apr_sleep(pause);
256258
return OK;
257259
}
@@ -295,7 +297,7 @@ static void unique_id_child_init(apr_pool_t *p, server_rec *s)
295297
/* Some systems have very low variance on the low end of their system
296298
* counter, defend against that.
297299
*/
298-
cur_unique_id.counter = (unsigned short)(tv % APR_USEC_PER_SEC / 10);
300+
cur_unique_id.counter = (unsigned short)(apr_time_usec(tv) / 10);
299301

300302
/*
301303
* We must always use network ordering for these bytes, so that

modules/metadata/mod_usertrack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ static void make_cookie(request_rec *r)
157157
if ((dcfg->style == CT_UNSET) || (dcfg->style == CT_NETSCAPE)) {
158158
apr_time_exp_t tms;
159159
apr_time_exp_gmt(&tms, r->request_time
160-
+ cls->expires * APR_USEC_PER_SEC);
160+
+ apr_time_from_sec(cls->expires));
161161
new_cookie = apr_psprintf(r->pool,
162162
"%s; expires=%s, "
163163
"%.2d-%s-%.2d %.2d:%.2d:%.2d GMT",

0 commit comments

Comments
 (0)