Changeset 256
- Timestamp:
- 10/29/04 18:41:52 (9 years ago)
- Location:
- trunk/wifidog
- Files:
-
- 10 modified
-
ChangeLog (modified) (1 diff)
-
src/client_list.h (modified) (1 diff)
-
src/conf.h (modified) (1 diff)
-
src/firewall.c (modified) (4 diffs)
-
src/fw_iptables.c (modified) (8 diffs)
-
src/http.c (modified) (2 diffs)
-
src/ping_thread.c (modified) (3 diffs)
-
src/util.c (modified) (3 diffs)
-
src/util.h (modified) (1 diff)
-
src/wdctl_thread.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wifidog/ChangeLog
r255 r256 1 1 # $Header$ 2 3 2004-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 2 7 2004-10-28 Philippe April <philippe@philippeapril.com> 3 8 * ipkg/rules: building ipkg-tools before packaging -
trunk/wifidog/src/client_list.h
r170 r256 78 78 void client_list_delete(t_client *client); 79 79 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 80 92 #endif /* _CLIENT_LIST_H_ */ 81 -
trunk/wifidog/src/conf.h
r252 r256 131 131 void mark_auth_server_bad(t_auth_serv *); 132 132 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 133 145 #endif /* _CONFIG_H_ */ -
trunk/wifidog/src/firewall.c
r170 r256 153 153 } 154 154 155 pthread_mutex_lock(&client_list_mutex);155 LOCK_CLIENT_LIST(); 156 156 157 157 for (p1 = p2 = client_get_first_client(); NULL != p1; p1 = p2) { … … 164 164 incoming = p1->counters.outgoing; 165 165 166 pthread_mutex_unlock(&client_list_mutex);166 UNLOCK_CLIENT_LIST(); 167 167 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 170 170 if (!(p1 = client_list_find(ip, mac))) { 171 171 debug(LOG_ERR, "Node %s was freed while being re-validated!", ip); … … 180 180 181 181 /* Advertise the logout */ 182 pthread_mutex_unlock(&client_list_mutex);182 UNLOCK_CLIENT_LIST(); 183 183 auth_server_request(&authresponse, REQUEST_TYPE_LOGOUT, ip, mac, token, 0, 0); 184 pthread_mutex_lock(&client_list_mutex);184 LOCK_CLIENT_LIST(); 185 185 } else { 186 186 /* … … 229 229 free(mac); 230 230 } 231 pthread_mutex_unlock(&client_list_mutex);232 } 231 UNLOCK_CLIENT_LIST(); 232 } -
trunk/wifidog/src/fw_iptables.c
r252 r256 87 87 iptables_do_command("-t nat -A " TABLE_WIFIDOG_VALIDATE " -d %s -j ACCEPT", config->gw_address); 88 88 89 pthread_mutex_lock(&config_mutex);89 LOCK_CONFIG(); 90 90 91 91 for (auth_server = config->auth_servers; auth_server != NULL; … … 93 93 iptables_do_command("-t nat -A " TABLE_WIFIDOG_VALIDATE " -d %s -j ACCEPT", auth_server->authserv_hostname); 94 94 } 95 96 pthread_mutex_unlock(&config_mutex);95 96 UNLOCK_CONFIG(); 97 97 98 98 /** Insert global rules BEFORE the "defaults" */ … … 114 114 iptables_do_command("-t nat -A " TABLE_WIFIDOG_UNKNOWN " -d %s -j ACCEPT", config->gw_address); 115 115 116 pthread_mutex_lock(&config_mutex);116 LOCK_CONFIG(); 117 117 118 118 for (auth_server = config->auth_servers; auth_server != NULL; … … 121 121 } 122 122 123 pthread_mutex_unlock(&config_mutex);123 UNLOCK_CONFIG(); 124 124 125 125 /** Insert global rules BEFORE the "defaults" */ … … 257 257 if (2 == rc && EOF != rc) { 258 258 debug(LOG_DEBUG, "Outgoing %s Bytes=%ld", ip, counter); 259 pthread_mutex_lock(&client_list_mutex);259 LOCK_CLIENT_LIST(); 260 260 if ((p1 = client_list_find_by_ip(ip))) { 261 261 if (p1->counters.outgoing < counter) { … … 267 267 debug(LOG_ERR, "Could not find %s in client list", ip); 268 268 } 269 pthread_mutex_unlock(&client_list_mutex);269 UNLOCK_CLIENT_LIST(); 270 270 } 271 271 } … … 289 289 if (2 == rc && EOF != rc) { 290 290 debug(LOG_DEBUG, "Incoming %s Bytes=%ld", ip, counter); 291 pthread_mutex_lock(&client_list_mutex);291 LOCK_CLIENT_LIST(); 292 292 if ((p1 = client_list_find_by_ip(ip))) { 293 293 if (p1->counters.incoming < counter) { … … 299 299 debug(LOG_ERR, "Could not find %s in client list", ip); 300 300 } 301 pthread_mutex_unlock(&client_list_mutex);301 UNLOCK_CLIENT_LIST(); 302 302 } 303 303 } -
trunk/wifidog/src/http.c
r213 r256 139 139 /* We have their MAC address */ 140 140 141 pthread_mutex_lock(&client_list_mutex);141 LOCK_CLIENT_LIST(); 142 142 143 143 if ((client = client_list_find(webserver->clientAddr, mac)) == NULL) { … … 155 155 webserver->clientSock = -1; 156 156 157 pthread_mutex_unlock(&client_list_mutex);157 UNLOCK_CLIENT_LIST(); 158 158 159 159 /* That clientAddr may be freed prior to the thread -
trunk/wifidog/src/ping_thread.c
r252 r256 64 64 /* Make sure we check the servers at the very begining */ 65 65 /** @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()"); 66 67 ping(); 67 68 … … 108 109 auth_server->authserv_hostname); 109 110 111 debug(LOG_DEBUG, "Resolving IP"); 110 112 if ((h_addr = (struct in_addr *)wd_gethostbyname(auth_server->authserv_hostname)) == NULL) { 111 113 debug(LOG_ERR, "Failed to resolve %s via gethostbyname" … … 155 157 numbytes = totalbytes = 0; 156 158 while ((numbytes = read(sockfd, request + totalbytes, 157 MAX_BUF - (totalbytes + 1))) > 0) 159 MAX_BUF - (totalbytes + 1))) > 0) { 158 160 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); 159 166 160 167 if (numbytes == -1) { -
trunk/wifidog/src/util.c
r252 r256 100 100 return NULL; 101 101 102 pthread_mutex_lock(&ghbn_mutex);102 LOCK_GHBN(); 103 103 104 104 he = gethostbyname(name); … … 106 106 if (he == NULL) { 107 107 free(h_addr); 108 pthread_mutex_unlock(&ghbn_mutex);108 UNLOCK_GHBN(); 109 109 return NULL; 110 110 } … … 113 113 h_addr->s_addr = in_addr_temp->s_addr; 114 114 115 pthread_mutex_unlock(&ghbn_mutex);115 UNLOCK_GHBN(); 116 116 117 117 return h_addr; -
trunk/wifidog/src/util.h
r247 r256 33 33 struct in_addr *wd_gethostbyname(const char *name); 34 34 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 35 47 #endif /* _UTIL_H_ */ 36 48 -
trunk/wifidog/src/wdctl_thread.c
r244 r256 204 204 len = strlen(buffer); 205 205 206 pthread_mutex_lock(&client_list_mutex);206 LOCK_CLIENT_LIST(); 207 207 208 208 first = client_get_first_client(); … … 240 240 } 241 241 242 pthread_mutex_unlock(&client_list_mutex);242 UNLOCK_CLIENT_LIST(); 243 243 244 244 write(fd, buffer, len); … … 262 262 debug(LOG_DEBUG, "Entering wdctl_reset..."); 263 263 264 pthread_mutex_lock(&client_list_mutex); 265 264 LOCK_CLIENT_LIST(); 266 265 debug(LOG_DEBUG, "Argument: %s (@%x)", arg, arg); 267 266 … … 271 270 else { 272 271 debug(LOG_DEBUG, "Client not found."); 273 pthread_mutex_unlock(&client_list_mutex);272 UNLOCK_CLIENT_LIST(); 274 273 write(fd, "No", 2); 275 274 return; … … 284 283 client_list_delete(node); 285 284 286 pthread_mutex_unlock(&client_list_mutex);285 UNLOCK_CLIENT_LIST(); 287 286 288 287 write(fd, "Yes", 3);
