Changeset 5348


Ignore:
Timestamp:
Jun 3, 2011, 12:56:35 AM (8 years ago)
Author:
schlocke
Message:

changed locking behaviour on dns resolving, gethostbyname=mutexlock,
getaddrinfo=no mutex lock

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/module-gbox.c

    r5304 r5348  
    896896  memset((char *)&cli->udp_sa, 0, sizeof(cli->udp_sa));
    897897
    898   struct hostent *hp;
    899   hp = gethostbyname(rdr->device);
    900   memcpy((char *)&cli->udp_sa.sin_addr, (char *)hp->h_addr, hp->h_length);
     898  if (!hostResolve(rdr))
     899    return 1;
    901900
    902901  cli->udp_sa.sin_family=AF_INET;
  • trunk/oscam-reader.c

    r5340 r5348  
    111111   if(!cl) return 0;
    112112   
    113    while (cs_trylock(&gethostbyname_lock)) {
    114      cs_debug_mask(D_TRACE, "trylock hostResolve wait");
    115      cs_sleepms(50);
    116    }
    117    
    118113   in_addr_t last_ip = cl->ip;
    119114   
    120115   if (cfg.resolve_gethostbyname) { //Resolve with gethostbyname:
     116
     117     while (cs_trylock(&gethostbyname_lock)) {
     118       cs_debug_mask(D_TRACE, "trylock hostResolve wait");
     119       cs_sleepms(50);
     120     }
     121   
    121122     struct hostent *rht = gethostbyname(rdr->device);
    122123     if (!rht) {
     
    128129       result = 1;
    129130     }
     131     
     132     pthread_mutex_unlock(&gethostbyname_lock);
    130133   }
    131134   else { //Resolve with getaddrinfo:
     
    154157     cs_log("%s: resolved ip=%s", rdr->device, cs_inet_ntoa(cl->ip));
    155158   }
    156 
    157    pthread_mutex_unlock(&gethostbyname_lock);
    158159
    159160   return result;
  • trunk/oscam.c

    r5343 r5348  
    11321132    if (account->dyndns[0])
    11331133    {
    1134         cs_lock(&gethostbyname_lock);
    11351134        in_addr_t lastip = account->dynip;
    11361135        //Resolve with gethostbyname:
    11371136        if (cfg.resolve_gethostbyname) {
     1137            cs_lock(&gethostbyname_lock);
    11381138            rht = gethostbyname((char*)account->dyndns);
    11391139            if (!rht)
     
    11441144                result=1;
    11451145            }
     1146            cs_unlock(&gethostbyname_lock);
    11461147        }
    11471148        else { //Resolve with getaddrinfo:
     
    11651166            cs_log("%s: resolved ip=%s", (char*)account->dyndns, cs_inet_ntoa(account->dynip));
    11661167        }
    1167         cs_unlock(&gethostbyname_lock);
    11681168    }
    11691169    if (!result)
Note: See TracChangeset for help on using the changeset viewer.