Diff for /libwww/Library/src/HTDNS.c between versions 2.11 and 2.12

version 2.11, 1995/11/22 23:32:33 version 2.12, 1995/12/07 06:21:27
Line 37  struct _HTdns { Line 37  struct _HTdns {
     int                 version;                           /* Server version */      int                 version;                           /* Server version */
     HTTCPType           type;                             /* Connection type */      HTTCPType           type;                             /* Connection type */
   
     BOOL                active;                             /* Socket in use */      int                 active;                  /* Semaphor on Socket usage */
     time_t              expires;                      /* Socket expires time */      time_t              expires;                      /* Socket expires time */
     SOCKET              sockfd;                     /* Persistent connection */      SOCKET              sockfd;                     /* Persistent connection */
   
Line 59  PRIVATE void free_object (HTdns * me) Line 59  PRIVATE void free_object (HTdns * me)
     if (me) {      if (me) {
         FREE(me->hostname);          FREE(me->hostname);
         FREE(me->server);          FREE(me->server);
         if (me->sockfd != INVSOC && !me->active) {          if (me->sockfd != INVSOC && me->active <= 0) {
             NETCLOSE(me->sockfd);              NETCLOSE(me->sockfd);
             HTEvent_UnRegister(me->sockfd, (SockOps) FD_ALL);              HTEvent_UnRegister(me->sockfd, (SockOps) FD_ALL);
             HTList_removeObject(PersSock, me);              HTList_removeObject(PersSock, me);
Line 174  PUBLIC BOOL HTDNS_setSocket(HTdns *dns, Line 174  PUBLIC BOOL HTDNS_setSocket(HTdns *dns,
     if (!PersSock) PersSock = HTList_new();      if (!PersSock) PersSock = HTList_new();
     if (socket == INVSOC) {      if (socket == INVSOC) {
         dns->sockfd = socket;          dns->sockfd = socket;
         dns->active = NO;          dns->active = 0;
           if (dns->active < 0) dns->active = 0;
         dns->expires = 0;          dns->expires = 0;
         HTList_removeObject(PersSock, dns);          HTList_removeObject(PersSock, dns);
         return YES;          return YES;
     } else if (HTList_count(PersSock) < HTNet_maxSocket()-2) {      } else if (HTList_count(PersSock) < HTNet_maxSocket()-2) {
         dns->sockfd = socket;          dns->sockfd = socket;
         dns->active = YES;          if (dns->active <= 0) dns->active = 1;
         dns->expires = time(NULL) + TCPTimeout;           /* Default timeout */          dns->expires = time(NULL) + TCPTimeout;           /* Default timeout */
         HTList_addObject(PersSock, dns);          HTList_addObject(PersSock, dns);
         return YES;          return YES;
     }      }
       if (PROT_TRACE)
           TTYPrint(TDEST, "DNS Socket.. semaphor is %d for soc %d\n",
                    dns->active, dns->sockfd);
     return NO;      return NO;
 }  }
   
Line 196  PUBLIC int HTDNS_socketCount (void) Line 200  PUBLIC int HTDNS_socketCount (void)
 PUBLIC void HTDNS_clearActive (HTdns *dns)  PUBLIC void HTDNS_clearActive (HTdns *dns)
 {  {
     if (dns) {      if (dns) {
           dns->active--;  
           if (dns->active < 0) dns->active = 0;
         if (PROT_TRACE)          if (PROT_TRACE)
             TTYPrint(TDEST, "DNS Clear... Active bit for socket %d\n",              TTYPrint(TDEST, "DNS Clear... semaphor is %d for soc %d\n",
                     dns->sockfd);                       dns->active, dns->sockfd);
         dns->active = NO;  
     }      }
 }  }
   
Line 441  PUBLIC int HTGetHostByName (HTNet *net, Line 446  PUBLIC int HTGetHostByName (HTNet *net,
   
         /* See if we have an open connection already */          /* See if we have an open connection already */
         if (pres->sockfd != INVSOC) {          if (pres->sockfd != INVSOC) {
             if (pres->active) {                    /* Warm connection in use */              if (pres->active >= 0) {               /* Warm connection in use */
                 net->sockfd = pres->sockfd;                 /* Assign always */                  net->sockfd = pres->sockfd;                 /* Assign always */
                 if (pres->type == HT_TCP_INTERLEAVE) {                  pres->active++;
                   if (PROT_TRACE)
                       TTYPrint(TDEST,"HostByName.. semaphor is %d for soc %d\n",
                                pres->active, pres->sockfd);
                   if (pres->type == HT_TCP_PLAIN) {
                     if (PROT_TRACE)                      if (PROT_TRACE)
                         TTYPrint(TDEST, "HostByName.. waiting for socket\n");                          TTYPrint(TDEST, "HostByName.. waiting for socket %d\n",
                                    pres->sockfd);
                       net->dns = pres;
                     return 0;                   /* Wait for clear connection */                      return 0;                   /* Wait for clear connection */
                 }                  }
             } else if (pres->expires < time(NULL)) {          /* Gotton cold */              } else if (pres->expires < time(NULL)) {          /* Gotton cold */
Line 456  PUBLIC int HTGetHostByName (HTNet *net, Line 467  PUBLIC int HTGetHostByName (HTNet *net,
                 HTDNS_setSocket(pres, INVSOC);                  HTDNS_setSocket(pres, INVSOC);
             } else {                /* Warm connection is idle and ready :-) */              } else {                /* Warm connection is idle and ready :-) */
                 HTEvent_UnRegister(pres->sockfd, (SockOps) FD_ALL);                  HTEvent_UnRegister(pres->sockfd, (SockOps) FD_ALL);
                 pres->active = YES;                               pres->active = 1;
                   if (PROT_TRACE)
                       TTYPrint(TDEST,"HostByName.. semaphor is %d for soc %d\n",
                                pres->active, pres->sockfd);
                 net->sockfd = pres->sockfd;                  net->sockfd = pres->sockfd;
             }              }
         }          }

Removed from v.2.11  
changed lines
  Added in v.2.12


Webmaster