Changeset 256

Show
Ignore:
Timestamp:
10/29/04 18:41:52 (9 years ago)
Author:
alexcv
Message:

Extra mutex logging and extra logging in ping_thread()

Location:
trunk/wifidog
Files:
10 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog/ChangeLog

    r255 r256  
    11# $Header$ 
     2 
     32004-10-29 Alexandre Carmel-Veilleux <acv@acv.ca> 
     4        * src/ping_thread.c: Much new debugging information 
     5        * multiple files: Logging for all mutexes 
     6 
    272004-10-28 Philippe April <philippe@philippeapril.com> 
    38        * ipkg/rules: building ipkg-tools before packaging 
  • trunk/wifidog/src/client_list.h

    r170 r256  
    7878void client_list_delete(t_client *client); 
    7979 
     80#define LOCK_CLIENT_LIST() do { \ 
     81        debug(LOG_DEBUG, "Locking client list"); \ 
     82        pthread_mutex_lock(&client_list_mutex); \ 
     83        debug(LOG_DEBUG, "Client list locked"); \ 
     84} while (0) 
     85 
     86#define UNLOCK_CLIENT_LIST() do { \ 
     87        debug(LOG_DEBUG, "Unlocking client list"); \ 
     88        pthread_mutex_unlock(&client_list_mutex); \ 
     89        debug(LOG_DEBUG, "Client list unlocked"); \ 
     90} while (0) 
     91 
    8092#endif /* _CLIENT_LIST_H_ */ 
    81  
  • trunk/wifidog/src/conf.h

    r252 r256  
    131131void mark_auth_server_bad(t_auth_serv *); 
    132132 
     133#define LOCK_CONFIG() do { \ 
     134        debug(LOG_DEBUG, "Locking config"); \ 
     135        pthread_mutex_lock(&config_mutex); \ 
     136        debug(LOG_DEBUG, "Config locked"); \ 
     137} while (0) 
     138 
     139#define UNLOCK_CONFIG() do { \ 
     140        debug(LOG_DEBUG, "Unlocking config"); \ 
     141        pthread_mutex_unlock(&config_mutex); \ 
     142        debug(LOG_DEBUG, "Config unlocked"); \ 
     143} while (0) 
     144 
    133145#endif /* _CONFIG_H_ */ 
  • trunk/wifidog/src/firewall.c

    r170 r256  
    153153    } 
    154154 
    155     pthread_mutex_lock(&client_list_mutex); 
     155    LOCK_CLIENT_LIST(); 
    156156 
    157157    for (p1 = p2 = client_get_first_client(); NULL != p1; p1 = p2) { 
     
    164164        incoming = p1->counters.outgoing; 
    165165 
    166         pthread_mutex_unlock(&client_list_mutex); 
     166        UNLOCK_CLIENT_LIST(); 
    167167        auth_server_request(&authresponse, REQUEST_TYPE_COUNTERS, ip, mac, token, incoming, outgoing); 
    168         pthread_mutex_lock(&client_list_mutex); 
    169  
     168        LOCK_CLIENT_LIST(); 
     169         
    170170        if (!(p1 = client_list_find(ip, mac))) { 
    171171            debug(LOG_ERR, "Node %s was freed while being re-validated!", ip); 
     
    180180 
    181181                /* Advertise the logout */ 
    182                 pthread_mutex_unlock(&client_list_mutex); 
     182                UNLOCK_CLIENT_LIST(); 
    183183                auth_server_request(&authresponse, REQUEST_TYPE_LOGOUT, ip, mac, token, 0, 0); 
    184                 pthread_mutex_lock(&client_list_mutex); 
     184                LOCK_CLIENT_LIST(); 
    185185            } else { 
    186186                /* 
     
    229229        free(mac); 
    230230    } 
    231     pthread_mutex_unlock(&client_list_mutex); 
    232 } 
     231    UNLOCK_CLIENT_LIST(); 
     232} 
  • trunk/wifidog/src/fw_iptables.c

    r252 r256  
    8787    iptables_do_command("-t nat -A " TABLE_WIFIDOG_VALIDATE " -d %s -j ACCEPT", config->gw_address); 
    8888 
    89     pthread_mutex_lock(&config_mutex); 
     89    LOCK_CONFIG(); 
    9090     
    9191    for (auth_server = config->auth_servers; auth_server != NULL; 
     
    9393        iptables_do_command("-t nat -A " TABLE_WIFIDOG_VALIDATE " -d %s -j ACCEPT", auth_server->authserv_hostname); 
    9494    } 
    95      
    96     pthread_mutex_unlock(&config_mutex); 
     95 
     96    UNLOCK_CONFIG(); 
    9797 
    9898    /** Insert global rules BEFORE the "defaults" */ 
     
    114114    iptables_do_command("-t nat -A " TABLE_WIFIDOG_UNKNOWN " -d %s -j ACCEPT", config->gw_address); 
    115115 
    116     pthread_mutex_lock(&config_mutex); 
     116    LOCK_CONFIG(); 
    117117     
    118118    for (auth_server = config->auth_servers; auth_server != NULL; 
     
    121121    } 
    122122 
    123     pthread_mutex_unlock(&config_mutex); 
     123    UNLOCK_CONFIG(); 
    124124 
    125125    /** Insert global rules BEFORE the "defaults" */ 
     
    257257        if (2 == rc && EOF != rc) { 
    258258            debug(LOG_DEBUG, "Outgoing %s Bytes=%ld", ip, counter); 
    259             pthread_mutex_lock(&client_list_mutex); 
     259            LOCK_CLIENT_LIST(); 
    260260            if ((p1 = client_list_find_by_ip(ip))) { 
    261261                if (p1->counters.outgoing < counter) { 
     
    267267                debug(LOG_ERR, "Could not find %s in client list", ip); 
    268268            } 
    269             pthread_mutex_unlock(&client_list_mutex); 
     269            UNLOCK_CLIENT_LIST(); 
    270270        } 
    271271    } 
     
    289289        if (2 == rc && EOF != rc) { 
    290290            debug(LOG_DEBUG, "Incoming %s Bytes=%ld", ip, counter); 
    291             pthread_mutex_lock(&client_list_mutex); 
     291            LOCK_CLIENT_LIST(); 
    292292            if ((p1 = client_list_find_by_ip(ip))) { 
    293293                if (p1->counters.incoming < counter) { 
     
    299299                debug(LOG_ERR, "Could not find %s in client list", ip); 
    300300            } 
    301             pthread_mutex_unlock(&client_list_mutex); 
     301            UNLOCK_CLIENT_LIST(); 
    302302        } 
    303303    } 
  • trunk/wifidog/src/http.c

    r213 r256  
    139139                        /* We have their MAC address */ 
    140140 
    141                         pthread_mutex_lock(&client_list_mutex); 
     141                        LOCK_CLIENT_LIST(); 
    142142                         
    143143                        if ((client = client_list_find(webserver->clientAddr, mac)) == NULL) { 
     
    155155                        webserver->clientSock = -1; 
    156156 
    157                         pthread_mutex_unlock(&client_list_mutex); 
     157                        UNLOCK_CLIENT_LIST(); 
    158158 
    159159                        /* That clientAddr may be freed prior to the thread 
  • trunk/wifidog/src/ping_thread.c

    r252 r256  
    6464                /* Make sure we check the servers at the very begining */ 
    6565                /** @todo  Note that this will only help if the second server responds.  The logic of the ping itslef should be changed so it iterates in the list until it finds one that responds ox exausts the list */ 
     66                debug(LOG_DEBUG, "Running ping()"); 
    6667                ping(); 
    6768                 
     
    108109                        auth_server->authserv_hostname); 
    109110         
     111        debug(LOG_DEBUG, "Resolving IP"); 
    110112        if ((h_addr = (struct in_addr *)wd_gethostbyname(auth_server->authserv_hostname)) == NULL) { 
    111113                debug(LOG_ERR, "Failed to resolve %s via gethostbyname" 
     
    155157        numbytes = totalbytes = 0; 
    156158        while ((numbytes = read(sockfd, request + totalbytes,  
    157                                 MAX_BUF - (totalbytes + 1))) > 0) 
     159                                MAX_BUF - (totalbytes + 1))) > 0) { 
    158160                totalbytes =+ numbytes; 
     161                debug(LOG_DEBUG, "Read %d bytes, total now %d", numbytes, 
     162                                totalbytes); 
     163        } 
     164 
     165        debug(LOG_DEBUG, "Done reading reply, total %d bytes", totalbytes); 
    159166         
    160167        if (numbytes == -1) { 
  • trunk/wifidog/src/util.c

    r252 r256  
    100100                return NULL; 
    101101         
    102         pthread_mutex_lock(&ghbn_mutex); 
     102        LOCK_GHBN(); 
    103103 
    104104        he = gethostbyname(name); 
     
    106106        if (he == NULL) { 
    107107                free(h_addr); 
    108                 pthread_mutex_unlock(&ghbn_mutex); 
     108                UNLOCK_GHBN(); 
    109109                return NULL; 
    110110        } 
     
    113113        h_addr->s_addr = in_addr_temp->s_addr; 
    114114         
    115         pthread_mutex_unlock(&ghbn_mutex); 
     115        UNLOCK_GHBN(); 
    116116 
    117117        return h_addr; 
  • trunk/wifidog/src/util.h

    r247 r256  
    3333struct in_addr *wd_gethostbyname(const char *name); 
    3434 
     35#define LOCK_GHBN() do { \ 
     36        debug(LOG_DEBUG, "Locking wd_gethostbyname()"); \ 
     37        pthread_mutex_lock(&ghbn_mutex); \ 
     38        debug(LOG_DEBUG, "wd_gethostbyname() locked"); \ 
     39} while (0) 
     40 
     41#define UNLOCK_CONFIG() do { \ 
     42        debug(LOG_DEBUG, "Unlocking wd_gethostbyname()"); \ 
     43        pthread_mutex_unlock(&ghbn_mutex); \ 
     44        debug(LOG_DEBUG, "wd_gethostbyname() unlocked"); \ 
     45} while (0) 
     46 
    3547#endif /* _UTIL_H_ */ 
    3648 
  • trunk/wifidog/src/wdctl_thread.c

    r244 r256  
    204204        len = strlen(buffer); 
    205205 
    206         pthread_mutex_lock(&client_list_mutex); 
     206        LOCK_CLIENT_LIST(); 
    207207         
    208208        first = client_get_first_client(); 
     
    240240        } 
    241241         
    242         pthread_mutex_unlock(&client_list_mutex); 
     242        UNLOCK_CLIENT_LIST(); 
    243243         
    244244        write(fd, buffer, len); 
     
    262262        debug(LOG_DEBUG, "Entering wdctl_reset..."); 
    263263         
    264         pthread_mutex_lock(&client_list_mutex); 
    265  
     264        LOCK_CLIENT_LIST(); 
    266265        debug(LOG_DEBUG, "Argument: %s (@%x)", arg, arg); 
    267266         
     
    271270        else { 
    272271                debug(LOG_DEBUG, "Client not found."); 
    273                 pthread_mutex_unlock(&client_list_mutex); 
     272                UNLOCK_CLIENT_LIST(); 
    274273                write(fd, "No", 2); 
    275274                return; 
     
    284283        client_list_delete(node); 
    285284         
    286         pthread_mutex_unlock(&client_list_mutex); 
     285        UNLOCK_CLIENT_LIST(); 
    287286         
    288287        write(fd, "Yes", 3);