#6 Cope with unsigned time_t type

stable (4)

While porting ht://Dig to OpenVMS/Alpha, I saw a program hang
due to the fact that the time arithmetic in
htdig/server.cc:Server::delay overflows if time_t is an unsigned
type (which is the case in Compaq C++). To remedy it, just
rearrange the calculation:

diff -cdrN orig/htdig/server.cc
*** orig/htdig/server.cc Thu Jan 31
23:47:16 2002
--- vms/htdig/server.cc Thu Oct 4 18:17:02
*** 287,296 ****
time_t now = time(0);
! time_t
how_long = _connection_space + _last_connection - now;
_last_connection = now; // Reset the clock for the next delay!
! if
(how_long > 0)

287,298 ----
void Server::delay()
time_t now =
! if (_connection_space > now - _last_connection)
! time_t how_long = _connection_space - (now -
+ }
_last_connection = now; // Reset the clock for the next delay!


Some other issues in the port (more VMS
- file handling in htcommon/wordlist.cc: changed to
only open the wordlist file once.
- externalparser.cc: no fork() on
VMS - used the 3.1.5 code
- system() calls for sorting: replaced
by system API
- filenames may only contain one dot: changed
to use underscore
- CGI variables: added support for WWW_*
variants (still used by some VMS

Anyway: the port was comparably easy.
What a great piece of software! Thanks.


  • Gilles Detillieux

    • assigned_to: nobody --> grdetil
  • Gilles Detillieux

    Logged In: YES

    Thanks for your report. The SourceForge patches facility hasn't been working out all that well for us, so we
    prefer to get patches mailed to the htdig-dev or htdig-general mailing lists. I'm very interested in seeing all
    the patches you've made to 3.1.6 to get it to run on OpenVMS, though, so I would be greatful if you did post
    complete patches. Given that for ExternalParser.cc, you simply went back to 3.1.5 code, I'd have to figure
    out some #ifdefs to allow going back to the old code, and add a ./configure test for the fork() call. I was a
    bit concerned about the portability of the new code, but it was requested to avoid security risks associated
    with popen().

    I'm curious about this "system API" you mention. It seems odd to me that OpenVMS supports the popen()
    call in the 3.1.5 ExternalParser.cc code, but not the system() function used in htmerge/words.cc. I'm also
    interested in knowing how you implemented the changes to htcommon/WordList.cc, and when the file gets
    closed in your code, as well as why you had to do this for OpenVMS. I'm guessing it was for efficiency, or to
    get around VMS making several versions of the file.

    As there likely will be a 3.1.7 release sometime later this year, it would be good to have it build "right out of
    the box" on VMS. Please also let us know which version of OpenVMS and Compaq C++ you tested this on.


  • Nobody/Anonymous

    Logged In: NO

    I'm sorry. I don't know the technology. I am very
    grateful and wish to express my gratitude for what you
    have done. You've helped me quite a bit (in spite of
    myself). You are a gentleman and quite generous and
    patient. I hope I figure out what's left to figure out
    and I certainly hope that my girlfriend and I have a
    chance to meet you in person and perhaps take you out for
    supper. I am overwhelmed at your patience and generosity.
    I can't even get Knoppix to recognize a DVD. Again, thanks
    very much. (This is Dottie, Jim's girlfriend. He has
    been trying to learn this all by himself for about 18 to
    20 hours a day for months. I, too, really appreciate your
    help. Maybe now he will calm down some!)


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks