Revert "TS-1355: Remove support for Unices which do not support 64bit time_t"
This reverts commit ede9cd51b3a9b840df6e03775e76bf9bb3149339. Following the comments to TS-1355, I am reverting this commit, because it fixes nothing, and breaks 32bit Linux builds. Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/d91904cf Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/d91904cf Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/d91904cf Branch: refs/heads/master Commit: d91904cf68a36829c4e22e7a15ea7cfe18b1a697 Parents: 758d865 Author: Igor GaliÄ <[email protected]> Authored: Thu Jul 26 17:16:55 2012 +0200 Committer: Igor GaliÄ <[email protected]> Committed: Thu Jul 26 17:16:55 2012 +0200 ---------------------------------------------------------------------- proxy/hdrs/MIME.h | 11 +++++++++-- proxy/http/HttpTransact.cc | 8 ++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d91904cf/proxy/hdrs/MIME.h ---------------------------------------------------------------------- diff --git a/proxy/hdrs/MIME.h b/proxy/hdrs/MIME.h index 77c4b5d..9664e27 100644 --- a/proxy/hdrs/MIME.h +++ b/proxy/hdrs/MIME.h @@ -1358,6 +1358,9 @@ MIMEHdr::get_age() if (age < 0) // We should ignore negative Age: values return 0; + if ((4 == sizeof(time_t)) && (age > INT_MAX)) // Overflow + return -1; + return age; } @@ -1526,7 +1529,11 @@ MIMEHdr::set_age(time_t value) if (value < 0) value_set_uint(MIME_FIELD_AGE, MIME_LEN_AGE, (uint32_t)INT_MAX + 1); else { - value_set_uint(MIME_FIELD_AGE, MIME_LEN_AGE, value); + if (sizeof(time_t) > 4) { + value_set_int64(MIME_FIELD_AGE, MIME_LEN_AGE, value); + } else { + value_set_uint(MIME_FIELD_AGE, MIME_LEN_AGE, value); + } } } @@ -1590,7 +1597,7 @@ MIMEHdr::set_last_modified(time_t value) inline void MIMEHdr::set_max_forwards(int32_t value) { - value_set_int64(MIME_FIELD_MAX_FORWARDS, MIME_LEN_MAX_FORWARDS, value); + value_set_int(MIME_FIELD_MAX_FORWARDS, MIME_LEN_MAX_FORWARDS, value); } /*------------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/d91904cf/proxy/http/HttpTransact.cc ---------------------------------------------------------------------- diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc index d4db071..4d34b01 100644 --- a/proxy/http/HttpTransact.cc +++ b/proxy/http/HttpTransact.cc @@ -8345,8 +8345,12 @@ ink_cluster_time(void) old = global_time; while (local_time > global_time) { - if (ink_atomic_cas64((int64_t *) & global_time, *((int64_t *) & old), *((int64_t *) & local_time))) { - break; + if (sizeof(ink_time_t) == 4) { + if (ink_atomic_cas((int32_t *) & global_time, *((int32_t *) & old), *((int32_t *) & local_time))) + break; + } else if (sizeof(ink_time_t) == 8) { + if (ink_atomic_cas64((int64_t *) & global_time, *((int64_t *) & old), *((int64_t *) & local_time))) + break; } old = global_time; }
