[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

lynx-dev [BUG] Race condition in LYGetHostByName on WinNT

From: Alexei Anatski
Subject: lynx-dev [BUG] Race condition in LYGetHostByName on WinNT
Date: Wed, 5 Apr 2000 14:44:15 +0400


Sometime Lynx on WinNT hangs with "Looking up" message chewing
100% CPU time. I traced the problem to race condition in LYGetHostByName.
If threa spawned for name lookup terminates before "donelookup = FALSE" then
"while (!donelookup)" loop is endless.

Quick fix: move "donelookup = FALSE" before CreateThread call.

There are more problems:
    MessageBox used instead of CTRACE
    CloseThread not called on "success" path
    "while (!donelookup)"  loop takes 100% CPU while lookup is in progress.

But these may wait for 2.8.4dev1.

Unfortunatly I have no time now to rewrite this function.

WWW\Library\Implementation\HTTP.c, 1082

 } else {  /* for Windows NT */
     phost = (struct hostent *) NULL;
     hThread = CreateThread((void *)NULL, 4096UL,
  (void *)NULL, 0UL, (unsigned long *)&dwThreadID);
     if (!hThread)
  MessageBox((void *)NULL, "CreateThread",
      "CreateThread Failed", 0L);

     donelookup = FALSE;
     while (!donelookup) {
  if (HTCheckForInterrupt()) {
      /* Note that host is a character array and is not freed */
      /* to avoid possible subthread problems: */
      if (!CloseHandle(hThread)) {
   MessageBox((void *)NULL,
       "CloseHandle","CloseHandle Failed", 0L);
      lynx_nsl_status = HT_INTERRUPTED;
      return NULL;

---- Alexei Anatski <address@hidden>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]