Ignore:
Timestamp:
May 26, 2009, 9:44:50 AM (16 years ago)
Author:
Herwig Bauernfeind
Message:

Update 3.2 branch to 3.2.6

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.2.x/source/nsswitch/wins.c

    r136 r228  
    2424
    2525#include <ns_daemon.h>
     26#endif
     27
     28#if HAVE_PTHREAD_H
     29#include <pthread.h>
     30#endif
     31
     32#if HAVE_PTHREAD
     33static pthread_mutex_t wins_nss_mutex = PTHREAD_MUTEX_INITIALIZER;
    2634#endif
    2735
     
    322330                          char *buffer, size_t buflen, int *h_errnop)
    323331{
     332        NSS_STATUS nss_status = NSS_STATUS_SUCCESS;
    324333        struct in_addr *ip_list;
    325334        int i, count;
     
    327336        size_t namelen;
    328337               
     338#if HAVE_PTHREAD
     339        pthread_mutex_lock(&wins_nss_mutex);
     340#endif
     341
    329342        memset(he, '\0', sizeof(*he));
    330343        fstrcpy(name, hostname);
     
    334347        ip_list = lookup_byname_backend(name, &count);
    335348
    336         if (!ip_list)
    337                 return NSS_STATUS_NOTFOUND;
     349        if (!ip_list) {
     350                nss_status = NSS_STATUS_NOTFOUND;
     351                goto out;
     352        }
    338353
    339354        /* Copy h_name */
     
    343358        if ((he->h_name = get_static(&buffer, &buflen, namelen)) == NULL) {
    344359                free(ip_list);
    345                 return NSS_STATUS_TRYAGAIN;
     360                nss_status = NSS_STATUS_TRYAGAIN;
     361                goto out;
    346362        }
    347363
     
    355371        if (get_static(&buffer, &buflen, i) == NULL) {
    356372                free(ip_list);
    357                 return NSS_STATUS_TRYAGAIN;
     373                nss_status = NSS_STATUS_TRYAGAIN;
     374                goto out;
    358375        }
    359376
     
    361378                     &buffer, &buflen, (count + 1) * sizeof(char *))) == NULL) {
    362379                free(ip_list);
    363                 return NSS_STATUS_TRYAGAIN;
     380                nss_status = NSS_STATUS_TRYAGAIN;
     381                goto out;
    364382        }
    365383
     
    368386                                                     INADDRSZ)) == NULL) {
    369387                        free(ip_list);
    370                         return NSS_STATUS_TRYAGAIN;
     388                        nss_status = NSS_STATUS_TRYAGAIN;
     389                        goto out;
    371390                }
    372391                memcpy(he->h_addr_list[i], &ip_list[i], INADDRSZ);
     
    387406                i = sizeof(char*) - i;
    388407
    389         if (get_static(&buffer, &buflen, i) == NULL)
    390                 return NSS_STATUS_TRYAGAIN;
     408        if (get_static(&buffer, &buflen, i) == NULL) {
     409                nss_status = NSS_STATUS_TRYAGAIN;
     410                goto out;
     411        }
    391412
    392413        if ((he->h_aliases = (char **)get_static(
    393                      &buffer, &buflen, sizeof(char *))) == NULL)
    394                 return NSS_STATUS_TRYAGAIN;
     414                     &buffer, &buflen, sizeof(char *))) == NULL) {
     415                nss_status = NSS_STATUS_TRYAGAIN;
     416                goto out;
     417        }
    395418
    396419        he->h_aliases[0] = NULL;
    397420
    398         return NSS_STATUS_SUCCESS;
     421        nss_status = NSS_STATUS_SUCCESS;
     422
     423  out:
     424
     425#if HAVE_PTHREAD
     426        pthread_mutex_unlock(&wins_nss_mutex);
     427#endif
     428        return nss_status;
    399429}
    400430
     
    404434                           char *buffer, size_t buflen, int *h_errnop)
    405435{
     436        NSS_STATUS nss_status;
     437
    406438        if(af!=AF_INET) {
    407439                *h_errnop = NO_DATA;
    408                 return NSS_STATUS_UNAVAIL;
    409         }
    410 
    411         return _nss_wins_gethostbyname_r(
    412                 name, he, buffer, buflen, h_errnop);
    413 }
    414 #endif
     440                nss_status = NSS_STATUS_UNAVAIL;
     441        } else {
     442                nss_status = _nss_wins_gethostbyname_r(
     443                                name, he, buffer, buflen, h_errnop);
     444        }
     445        return nss_status;
     446}
     447#endif
Note: See TracChangeset for help on using the changeset viewer.