64-bit time_t compatibility

This commit is contained in:
Igor Sysoev 2007-11-15 14:26:36 +00:00
parent a7e01da163
commit 1d04b14c09
7 changed files with 14 additions and 12 deletions

View File

@ -205,16 +205,16 @@ ngx_gmtime(time_t t, ngx_tm_t *tp)
{
ngx_int_t sec, min, hour, mday, mon, year, wday, yday, days;
days = t / 86400;
days = (ngx_int_t) (t / 86400);
/* Jaunary 1, 1970 was Thursday */
wday = (4 + days) % 7;
t %= 86400;
hour = t / 3600;
hour = (ngx_int_t) (t / 3600);
t %= 3600;
min = t / 60;
sec = t % 60;
min = (ngx_int_t) (t / 60);
sec = (ngx_int_t) (t % 60);
/* the algorithm based on Gauss's formula */

View File

@ -400,7 +400,8 @@ ngx_http_log_request_time(ngx_http_request_t *r, u_char *buf,
tp = ngx_timeofday();
ms = (tp->sec - r->start_sec) * 1000 + (tp->msec - r->start_msec);
ms = (ngx_msec_int_t)
((tp->sec - r->start_sec) * 1000 + (tp->msec - r->start_msec));
ms = (ms >= 0) ? ms : 0;
return ngx_sprintf(buf, "%T.%03M", ms / 1000, ms % 1000);

View File

@ -318,7 +318,7 @@ ngx_http_userid_set_uid(ngx_http_request_t *r, ngx_http_userid_ctx_t *ctx,
} else {
ctx->uid_set[0] = conf->service;
}
ctx->uid_set[1] = ngx_time();
ctx->uid_set[1] = (uint32_t) ngx_time();
ctx->uid_set[2] = ngx_pid;
ctx->uid_set[3] = sequencer_v1;
sequencer_v1 += 0x100;
@ -345,7 +345,7 @@ ngx_http_userid_set_uid(ngx_http_request_t *r, ngx_http_userid_ctx_t *ctx,
ctx->uid_set[0] = htonl(conf->service);
}
ctx->uid_set[1] = htonl(ngx_time());
ctx->uid_set[1] = htonl((uint32_t) ngx_time());
ctx->uid_set[2] = htonl(ngx_pid);
ctx->uid_set[3] = htonl(sequencer_v2);
sequencer_v2 += 0x100;

View File

@ -2341,7 +2341,7 @@ ngx_http_lingering_close_handler(ngx_event_t *rev)
return;
}
timer = r->lingering_time - ngx_time();
timer = (ngx_msec_t) (r->lingering_time - ngx_time());
if (timer <= 0) {
ngx_http_close_request(r, 0);
return;

View File

@ -493,7 +493,7 @@ ngx_http_read_discarded_request_body_handler(ngx_http_request_t *r)
}
if (r->lingering_time) {
timer = r->lingering_time - ngx_time();
timer = (ngx_msec_t) (r->lingering_time - ngx_time());
if (timer <= 0) {
r->discard_body = 0;

View File

@ -2873,7 +2873,8 @@ ngx_http_upstream_response_time_variable(ngx_http_request_t *r,
for ( ;; ) {
if (state[i].status) {
ms = state[i].response_sec * 1000 + state[i].response_msec;
ms = (ngx_msec_int_t)
(state[i].response_sec * 1000 + state[i].response_msec);
ms = (ms >= 0) ? ms : 0;
p = ngx_sprintf(p, "%d.%03d", ms / 1000, ms % 1000);

View File

@ -718,7 +718,7 @@ ngx_mail_auth_http_process_headers(ngx_mail_session_t *s,
return;
}
ngx_add_timer(s->connection->read, timer * 1000);
ngx_add_timer(s->connection->read, (ngx_msec_t) (timer * 1000));
s->connection->read->handler = ngx_mail_auth_sleep_handler;
@ -735,7 +735,7 @@ ngx_mail_auth_http_process_headers(ngx_mail_session_t *s,
return;
}
ngx_add_timer(s->connection->read, timer * 1000);
ngx_add_timer(s->connection->read, (ngx_msec_t) (timer * 1000));
s->connection->read->handler = ngx_mail_auth_sleep_handler;