From 1d04b14c09ee678a184c0acbd91b532110c02dd9 Mon Sep 17 00:00:00 2001 From: Igor Sysoev Date: Thu, 15 Nov 2007 14:26:36 +0000 Subject: [PATCH] 64-bit time_t compatibility --- src/core/ngx_times.c | 8 ++++---- src/http/modules/ngx_http_log_module.c | 3 ++- src/http/modules/ngx_http_userid_filter_module.c | 4 ++-- src/http/ngx_http_request.c | 2 +- src/http/ngx_http_request_body.c | 2 +- src/http/ngx_http_upstream.c | 3 ++- src/mail/ngx_mail_auth_http_module.c | 4 ++-- 7 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/core/ngx_times.c b/src/core/ngx_times.c index 551e10258..949e0c6f7 100644 --- a/src/core/ngx_times.c +++ b/src/core/ngx_times.c @@ -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 */ diff --git a/src/http/modules/ngx_http_log_module.c b/src/http/modules/ngx_http_log_module.c index fb7b26c49..157b15c2a 100644 --- a/src/http/modules/ngx_http_log_module.c +++ b/src/http/modules/ngx_http_log_module.c @@ -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); diff --git a/src/http/modules/ngx_http_userid_filter_module.c b/src/http/modules/ngx_http_userid_filter_module.c index 5587b002a..82a9fdfbd 100644 --- a/src/http/modules/ngx_http_userid_filter_module.c +++ b/src/http/modules/ngx_http_userid_filter_module.c @@ -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; diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c index c1dc3a6b7..86f244629 100644 --- a/src/http/ngx_http_request.c +++ b/src/http/ngx_http_request.c @@ -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; diff --git a/src/http/ngx_http_request_body.c b/src/http/ngx_http_request_body.c index a9583c706..a5b6813a2 100644 --- a/src/http/ngx_http_request_body.c +++ b/src/http/ngx_http_request_body.c @@ -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; diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c index c6de92bfc..0c36925d9 100644 --- a/src/http/ngx_http_upstream.c +++ b/src/http/ngx_http_upstream.c @@ -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); diff --git a/src/mail/ngx_mail_auth_http_module.c b/src/mail/ngx_mail_auth_http_module.c index 0bde162e5..17e7861c0 100644 --- a/src/mail/ngx_mail_auth_http_module.c +++ b/src/mail/ngx_mail_auth_http_module.c @@ -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;