W3C home > Mailing lists > Public > www-lib@w3.org > October to December 2001

time_t, ms_t, overflow issues

From: Phil Nitschke <Phil.Nitschke@youramigo.com>
Date: 21 Nov 2001 18:21:00 +1030
To: www-lib@w3.org
Message-ID: <lxn11g4l5n.fsf@YourAmigo.com>
Hi all,

With many architectures still implementing an ms_t in a 32-bit integer,
isn't HTGetTimeInMillis() going to suffer fairly badly from arithmetic
overflow?

    struct timeval tp;
    gettimeofday(&tp, NULL);
    return(tp.tv_sec * 1000) + (tp.tv_usec / 1000);

(This message was written about 1006328788000 milliseconds after Epoch.)

Given that, can any of the code in HTDoConnect() that calls
HTDNS_updateWeigths() be trusted?
Similarly, won't there be problems with other code that uses ms_t?

Why does the HTNet structure need a connecttime field?  Isn't it asking
for trouble to have a time_t connecttime field when the HTHost structure
has a similarly named field implemented as a ms_t?

(I search the archives, but could not fund these topics being discussed
before.) 

-- 
Phil   +----------------------------------------------------------+(\
     _/_)    YourAmigo Pty Ltd     http://www.YourAmigo.com/      |( \
  _/// /   _ =================  Phone Intl.: +61-8-8211-9211  _   |_) )_
 (((( (|  /_)             mailto:Phil.Nitschke@YourAmigo.com (_\  |/ /)))
  \\\\ \_/ / Address:                            <standard>   \ \_/ ////
   \      /    80 Gilbert Street, Adelaide      <disclaimers>  \      /
    )   _/     South Australia  5000  Australia    <apply>      \_   (
   /   /----------------------------------------------------------\   \
  /   /                                                            \   \
Received on Wednesday, 21 November 2001 02:51:09 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 23 April 2007 18:18:40 GMT