Changeset 4402
- Timestamp:
- 10/03/06 10:02:26 (2 years ago)
- Files:
-
- wired/trunk/wired/accounts.c (modified) (4 diffs)
- wired/trunk/wired/chats.c (modified) (13 diffs)
- wired/trunk/wired/chats.h (modified) (1 diff)
- wired/trunk/wired/clients.c (modified) (9 diffs)
- wired/trunk/wired/clients.h (modified) (2 diffs)
- wired/trunk/wired/commands.c (modified) (19 diffs)
- wired/trunk/wired/news.c (modified) (1 diff)
- wired/trunk/wired/server.c (modified) (6 diffs)
- wired/trunk/wired/server.h (modified) (1 diff)
- wired/trunk/wired/trackers.c (modified) (19 diffs)
- wired/trunk/wired/transfers.c (modified) (14 diffs)
- wired/trunk/wired/transfers.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
wired/trunk/wired/accounts.c
r3899 r4402 595 595 596 596 void wd_accounts_reload_users(void) { 597 wi_ list_node_t *node;597 wi_enumerator_t *enumerator; 598 598 wd_client_t *client; 599 600 wi_list_rdlock(wd_clients); 601 WI_LIST_FOREACH(wd_clients, node, client) 599 600 wi_hash_rdlock(wd_clients); 601 602 enumerator = wi_hash_data_enumerator(wd_clients); 603 604 while((client = wi_enumerator_next_data(enumerator))) 602 605 _wd_accounts_reload_client(client); 603 wi_list_unlock(wd_clients); 606 607 wi_hash_unlock(wd_clients); 604 608 } 605 609 … … 647 651 648 652 static void _wd_accounts_reload_user(wi_string_t *name) { 649 wi_ list_node_t *node;653 wi_enumerator_t *enumerator; 650 654 wd_client_t *client; 651 655 652 wi_list_rdlock(wd_clients); 653 WI_LIST_FOREACH(wd_clients, node, client) { 656 wi_hash_rdlock(wd_clients); 657 658 enumerator = wi_hash_data_enumerator(wd_clients); 659 660 while((client = wi_enumerator_next_data(enumerator))) { 654 661 if(wi_is_equal(client->account->name, name)) 655 662 _wd_accounts_reload_client(client); 656 663 } 657 wi_list_unlock(wd_clients); 664 665 wi_hash_unlock(wd_clients); 658 666 } 659 667 … … 661 669 662 670 static void _wd_accounts_reload_group(wi_string_t *name) { 663 wi_ list_node_t *node;671 wi_enumerator_t *enumerator; 664 672 wd_client_t *client; 665 673 666 wi_list_rdlock(wd_clients); 667 WI_LIST_FOREACH(wd_clients, node, client) { 674 wi_hash_rdlock(wd_clients); 675 676 enumerator = wi_hash_data_enumerator(wd_clients); 677 678 while((client = wi_enumerator_next_data(enumerator))) { 668 679 if(wi_is_equal(client->account->group, name)) 669 680 _wd_accounts_reload_client(client); 670 681 } 671 wi_list_unlock(wd_clients); 682 683 wi_hash_unlock(wd_clients); 672 684 } 673 685 … … 693 705 wi_lock_unlock(client->flag_lock); 694 706 695 if(client->admin != admin) { 696 wd_broadcast_lock(); 707 if(client->admin != admin) 697 708 wd_client_broadcast_status(client); 698 wd_broadcast_unlock();699 }700 709 701 710 wd_client_lock_socket(client); wired/trunk/wired/chats.c
r4401 r4402 41 41 42 42 43 wd_chat_t *wd_public_chat; 44 43 45 static wi_hash_t *wd_chats; 44 46 … … 55 57 56 58 void wd_init_chats(void) { 57 wd_chat_t *chat;58 59 59 wd_chat_runtime_id = wi_runtime_register_class(&wd_chat_runtime_class); 60 60 61 61 wd_chats = wi_hash_init(wi_hash_alloc()); 62 62 63 chat = wd_chat_init_public_chat(wd_chat_alloc()); 64 wd_chats_add_chat(chat); 65 wi_release(chat); 63 wd_public_chat = wd_chat_init_public_chat(wd_chat_alloc()); 64 wd_chats_add_chat(wd_public_chat); 66 65 } 67 66 … … 97 96 98 97 wi_hash_rdlock(wd_chats); 99 chat = wi_ hash_data_for_key(wd_chats, wi_number_with_int32(chat->cid));98 chat = wi_autorelease(wi_retain(wi_hash_data_for_key(wd_chats, wi_number_with_int32(cid)))); 100 99 wi_hash_unlock(wd_chats); 101 100 … … 117 116 chat = wi_hash_data_for_key(wd_chats, key); 118 117 118 wi_array_wrlock(chat->clients); 119 119 wi_array_remove_data(chat->clients, client); 120 wi_array_unlock(chat->clients); 120 121 121 122 if(chat->cid != WD_PUBLIC_CID && wi_array_count(chat->clients) == 0) … … 212 213 213 214 if(chat) { 214 wi_ hash_rdlock(wd_chats);215 wi_array_rdlock(chat->clients); 215 216 216 217 enumerator = wi_array_data_enumerator(chat->clients); … … 224 225 } 225 226 226 wi_ hash_unlock(wd_chats);227 wi_array_unlock(chat->clients); 227 228 } 228 229 … … 233 234 234 235 void wd_chat_add_client(wd_chat_t *chat, wd_client_t *client) { 235 wd_broadcast_lock(); 236 wd_broadcast(chat->cid, 302, WI_STR("%u%c%u%c%u%c%u%c%u%c%#@%c%#@%c%#@%c%#@%c%#@%c%#@"), 236 wd_broadcast(chat, 302, WI_STR("%u%c%u%c%u%c%u%c%u%c%#@%c%#@%c%#@%c%#@%c%#@%c%#@"), 237 237 chat->cid, WD_FIELD_SEPARATOR, 238 238 client->uid, WD_FIELD_SEPARATOR, … … 246 246 client->status, WD_FIELD_SEPARATOR, 247 247 client->image); 248 wd_broadcast_unlock(); 249 250 wi_hash_wrlock(wd_chats); 248 249 wi_array_wrlock(chat->clients); 251 250 wi_array_add_data(chat->clients, client); 252 wi_ hash_unlock(wd_chats);251 wi_array_unlock(chat->clients); 253 252 254 253 if(chat->topic.topic) … … 259 258 260 259 void wd_chat_remove_client(wd_chat_t *chat, wd_client_t *client) { 261 wi_ hash_wrlock(wd_chats);260 wi_array_wrlock(chat->clients); 262 261 wi_array_remove_data(chat->clients, client); 263 264 if(chat->cid != WD_PUBLIC_CID && wi_array_count(chat->clients) == 0) 262 wi_array_unlock(chat->clients); 263 264 if(chat->cid != WD_PUBLIC_CID && wi_array_count(chat->clients) == 0) { 265 wi_hash_wrlock(wd_chats); 265 266 wi_hash_remove_data_for_key(wd_chats, wi_number_with_int32(chat->cid)); 266 267 wi_hash_unlock(wd_chats);267 wi_hash_unlock(wd_chats); 268 } 268 269 } 269 270 … … 274 275 wd_client_t *client; 275 276 276 wi_array_rdlock( wd_chats);277 wi_array_rdlock(chat->clients); 277 278 278 279 enumerator = wi_array_data_enumerator(chat->clients); … … 295 296 } 296 297 297 wi_array_unlock( wd_chats);298 wi_array_unlock(chat->clients); 298 299 299 300 wd_reply(311, WI_STR("%u"), chat->cid); … … 346 347 string = wi_date_iso8601_string(chat->topic.date); 347 348 348 wd_broadcast(chat ->cid, 341, WI_STR("%u%c%#@%c%#@%c%#@%c%#@%c%#@"),349 wd_broadcast(chat, 341, WI_STR("%u%c%#@%c%#@%c%#@%c%#@%c%#@"), 349 350 chat->cid, WD_FIELD_SEPARATOR, 350 351 chat->topic.nick, WD_FIELD_SEPARATOR, … … 354 355 chat->topic.topic); 355 356 } 357 358 359 360 void wd_chat_broadcast_leave(wd_chat_t *chat, wd_client_t *client) { 361 wd_broadcast(chat, 303, WI_STR("%u%c%u"), 362 chat->cid, WD_FIELD_SEPARATOR, 363 client->uid); 364 } wired/trunk/wired/chats.h
r4401 r4402 83 83 void wd_chat_reply_topic(wd_chat_t *); 84 84 void wd_chat_broadcast_topic(wd_chat_t *); 85 void wd_chat_broadcast_leave(wd_chat_t *, wd_client_t *); 85 86 86 87 88 extern wd_chat_t *wd_public_chat; 89 87 90 #endif /* WD_CHATS_H */ wired/trunk/wired/clients.c
r3850 r4402 56 56 static wi_timer_t *wd_clients_timer; 57 57 58 wi_ list_t *wd_clients;58 wi_hash_t *wd_clients; 59 59 60 60 static wi_runtime_id_t wd_client_runtime_id = WI_RUNTIME_ID_NULL; … … 72 72 wd_client_runtime_id = wi_runtime_register_class(&wd_client_runtime_class); 73 73 74 wd_clients = wi_ list_init(wi_list_alloc());74 wd_clients = wi_hash_init(wi_hash_alloc()); 75 75 76 76 wd_clients_timer = wi_timer_init_with_function(wi_timer_alloc(), … … 89 89 90 90 static void wd_update_clients(wi_timer_t *timer) { 91 wi_ list_node_t *node;91 wi_enumerator_t *enumerator; 92 92 wd_client_t *client; 93 93 wi_time_interval_t interval; 94 94 95 if(wi_list_count(wd_clients) > 0) { 95 wi_hash_rdlock(wd_clients); 96 97 if(wi_hash_count(wd_clients) > 0) { 96 98 interval = wi_time_interval(); 97 99 98 wd_broadcast_lock();99 wi_list_rdlock(wd_clients);100 WI_LIST_FOREACH(wd_clients, node, client) {100 enumerator = wi_hash_data_enumerator(wd_clients); 101 102 while((client = wi_enumerator_next_data(enumerator))) { 101 103 if(client->idle || client->state != WD_CLIENT_STATE_LOGGED_IN) 102 104 continue; … … 108 110 } 109 111 } 110 wi_list_unlock(wd_clients);111 wd_broadcast_unlock();112 112 } 113 114 wi_hash_unlock(wd_clients); 113 115 } 114 116 … … 118 120 wi_log_debug(WI_STR("Clients:")); 119 121 wi_log_debug(WI_STR("%@"), wd_clients); 122 } 123 124 125 126 #pragma mark - 127 128 void wd_clients_add_client(wd_client_t *client) { 129 wi_hash_wrlock(wd_clients); 130 wi_hash_set_data_for_key(wd_clients, client, wi_number_with_int32(client->uid)); 131 wi_hash_unlock(wd_clients); 132 } 133 134 135 136 void wd_clients_remove_client(wd_client_t *client) { 137 wd_chats_remove_client(client); 138 wd_transfers_remove_client(client); 139 140 wi_hash_wrlock(wd_clients); 141 wi_hash_remove_data_for_key(wd_clients, wi_number_with_int32(client->uid)); 142 wi_hash_unlock(wd_clients); 143 } 144 145 146 147 void wd_clients_remove_all_clients(void) { 148 wi_enumerator_t *enumerator; 149 wd_client_t *client; 150 151 wi_hash_wrlock(wd_clients); 152 153 enumerator = wi_hash_data_enumerator(wd_clients); 154 155 while((client = wi_enumerator_next_data(enumerator))) { 156 wd_chats_remove_client(client); 157 wd_transfers_remove_client(client); 158 } 159 160 wi_hash_remove_all_data(wd_clients); 161 162 wi_hash_unlock(wd_clients); 120 163 } 121 164 … … 199 242 static wd_uid_t uid; 200 243 201 if(wi_ list_count(wd_clients) == 0)244 if(wi_hash_count(wd_clients) == 0) 202 245 uid = 0; 203 246 … … 238 281 239 282 wd_client_t * wd_client_with_uid(wd_uid_t uid) { 240 wi_list_node_t *node; 241 wd_client_t *client, *value = NULL; 242 243 wi_list_rdlock(wd_clients); 244 WI_LIST_FOREACH(wd_clients, node, client) { 245 if(client->uid == uid) { 246 value = client; 247 248 break; 249 } 250 } 251 wi_list_unlock(wd_clients); 252 253 return value; 283 wd_client_t *client; 284 285 wi_hash_rdlock(wd_clients); 286 client = wi_autorelease(wi_retain(wi_hash_data_for_key(wd_clients, wi_number_with_int32(uid)))); 287 wi_hash_unlock(wd_clients); 288 289 return client; 254 290 } 255 291 … … 259 295 260 296 void wd_client_broadcast_status(wd_client_t *client) { 261 wd_broadcast( WD_PUBLIC_CID, 304, WI_STR("%u%c%u%c%u%c%u%c%#@%c%#@"),297 wd_broadcast(wd_public_chat, 304, WI_STR("%u%c%u%c%u%c%u%c%#@%c%#@"), 262 298 client->uid, WD_FIELD_SEPARATOR, 263 299 client->idle, WD_FIELD_SEPARATOR, … … 267 303 client->status); 268 304 } 269 270 271 272 void wd_client_broadcast_leave(wd_client_t *client, wd_cid_t cid) {273 wd_broadcast(cid, 303, WI_STR("%u%c%u"),274 cid, WD_FIELD_SEPARATOR,275 client->uid);276 }277 278 279 280 #pragma mark -281 282 void wd_clients_add_client(wd_client_t *client) {283 wi_list_wrlock(wd_clients);284 wi_list_append_data(wd_clients, client);285 wi_list_unlock(wd_clients);286 }287 288 289 290 void wd_clients_remove_client(wd_client_t *client) {291 wd_chats_remove_client(client);292 wd_transfers_remove_client(client);293 294 wi_list_wrlock(wd_clients);295 wi_list_remove_data(wd_clients, client);296 wi_list_unlock(wd_clients);297 }298 299 300 301 void wd_clients_remove_all_clients(void) {302 wi_list_node_t *node;303 wd_client_t *client;304 305 wi_list_wrlock(wd_clients);306 WI_LIST_FOREACH(wd_clients, node, client) {307 wd_chats_remove_client(client);308 wd_transfers_remove_client(client);309 }310 311 wi_list_remove_all_data(wd_clients);312 wi_list_unlock(wd_clients);313 }wired/trunk/wired/clients.h
r3847 r4402 91 91 void wd_dump_clients(void); 92 92 93 void wd_clients_add_client(wd_client_t *); 94 void wd_clients_remove_client(wd_client_t *); 95 void wd_clients_remove_all_clients(void); 96 93 97 wd_client_t * wd_client_alloc(void); 94 98 wd_client_t * wd_client_init_with_socket(wd_client_t *, wi_socket_t *); … … 103 107 104 108 void wd_client_broadcast_status(wd_client_t *); 105 void wd_client_broadcast_leave(wd_client_t *, unsigned int);106 107 void wd_clients_add_client(wd_client_t *);108 void wd_clients_remove_client(wd_client_t *);109 void wd_clients_remove_all_clients(void);110 109 111 110 112 extern wi_ list_t *wd_clients;111 extern wi_hash_t *wd_clients; 113 112 114 113 #endif /* WD_CLIENTS_H */ wired/trunk/wired/commands.c
r4401 r4402 283 283 client->state = WD_CLIENT_STATE_DISCONNECTED; 284 284 285 wd_broadcast_lock(); 286 wd_client_broadcast_leave(client, WD_PUBLIC_CID); 287 wd_broadcast_unlock(); 285 wd_chat_broadcast_leave(wd_public_chat, client); 288 286 } 289 287 … … 340 338 client->idle = false; 341 339 342 wd_broadcast_lock();343 340 wd_client_broadcast_status(client); 344 wd_broadcast_unlock();345 341 } 346 342 } … … 411 407 } 412 408 413 wd_broadcast_lock(); 414 wd_broadcast(WD_PUBLIC_CID, 307, WI_STR("%u%c%u%c%#@"), 409 wd_broadcast(wd_public_chat, 307, WI_STR("%u%c%u%c%#@"), 415 410 peer->uid, WD_FIELD_SEPARATOR, 416 411 client->uid, WD_FIELD_SEPARATOR, 417 412 WI_ARRAY(arguments, 1)); 418 wd_broadcast_unlock();419 413 420 414 wi_log_ll(WI_STR("%@/%@/%@ banned %@/%@/%@"), … … 455 449 } 456 450 457 wd_broadcast_lock(); 458 wd_broadcast(WD_PUBLIC_CID, 309, WI_STR("%u%c%#@"), 451 wd_broadcast(wd_public_chat, 309, WI_STR("%u%c%#@"), 459 452 client->uid, WD_FIELD_SEPARATOR, 460 453 WI_ARRAY(arguments, 0)); 461 wd_broadcast_unlock();462 454 } 463 455 … … 628 620 return; 629 621 630 wd_broadcast_lock(); 631 wd_broadcast(chat->cid, 332, WI_STR("%u%c%u"), 622 wd_broadcast(chat, 332, WI_STR("%u%c%u"), 632 623 chat->cid, WD_FIELD_SEPARATOR, 633 624 client->uid); 634 wd_broadcast_unlock();635 625 } 636 626 … … 977 967 client->icon = icon; 978 968 979 if(client->state == WD_CLIENT_STATE_LOGGED_IN) { 980 wd_broadcast_lock(); 969 if(client->state == WD_CLIENT_STATE_LOGGED_IN) 981 970 wd_client_broadcast_status(client); 982 wd_broadcast_unlock();983 }984 971 } 985 972 … … 990 977 991 978 if(client->state == WD_CLIENT_STATE_LOGGED_IN) { 992 wd_broadcast_lock(); 993 wd_broadcast(WD_PUBLIC_CID, 340, WI_STR("%u%c%#@"), 979 wd_broadcast(wd_public_chat, 340, WI_STR("%u%c%#@"), 994 980 client->uid, WD_FIELD_SEPARATOR, 995 981 client->image); 996 wd_broadcast_unlock();997 982 } 998 983 } … … 1007 992 static void wd_cmd_info(wi_array_t *arguments) { 1008 993 wd_client_t *client = wd_client(); 1009 wi_ list_node_t *node;994 wi_enumerator_t *enumerator; 1010 995 wi_string_t *info, *login, *idle, *downloads, *uploads; 1011 996 wd_client_t *peer; … … 1031 1016 uploads = wi_string(); 1032 1017 1033 wi_list_rdlock(wd_transfers); 1034 WI_LIST_FOREACH(wd_transfers, node, transfer) { 1018 wi_array_rdlock(wd_transfers); 1019 1020 enumerator = wi_array_data_enumerator(wd_transfers); 1021 1022 while((transfer = wi_enumerator_next_data(enumerator))) { 1035 1023 if(transfer->client == peer && transfer->state == WD_TRANSFER_RUNNING) { 1036 1024 if(!client->account->view_dropboxes) { … … 1058 1046 } 1059 1047 } 1060 wi_list_unlock(wd_transfers); 1048 1049 wi_array_unlock(wd_transfers); 1061 1050 1062 1051 login = wi_date_iso8601_string(wi_date_with_time_interval(peer->login_time)); … … 1179 1168 } 1180 1169 1181 wd_broadcast_lock(); 1182 wd_broadcast(WD_PUBLIC_CID, 306, WI_STR("%u%c%u%c%#@"), 1170 wd_broadcast(wd_public_chat, 306, WI_STR("%u%c%u%c%#@"), 1183 1171 peer->uid, WD_FIELD_SEPARATOR, 1184 1172 client->uid, WD_FIELD_SEPARATOR, 1185 1173 WI_ARRAY(arguments, 1)); 1186 wd_broadcast_unlock();1187 1174 1188 1175 wi_log_ll(WI_STR("%@/%@/%@ kicked %@/%@/%@"), … … 1217 1204 1218 1205 wd_chat_remove_client(chat, client); 1219 1220 wd_broadcast_lock(); 1221 wd_client_broadcast_leave(client, cid); 1222 wd_broadcast_unlock(); 1206 wd_chat_broadcast_leave(chat, client); 1223 1207 } 1224 1208 … … 1289 1273 count = wi_array_count(array); 1290 1274 1291 wd_broadcast_lock();1292 1275 for(i = 0; i < count; i++) { 1293 1276 string = WI_ARRAY(array, i); 1294 1277 1295 1278 if(wi_string_length(string) > 0) { 1296 wd_broadcast(c id, 301, WI_STR("%u%c%u%c%#@"),1279 wd_broadcast(chat, 301, WI_STR("%u%c%u%c%#@"), 1297 1280 cid, WD_FIELD_SEPARATOR, 1298 1281 client->uid, WD_FIELD_SEPARATOR, … … 1300 1283 } 1301 1284 } 1302 wd_broadcast_unlock();1303 1285 } 1304 1286 … … 1397 1379 client->nick = wi_retain(nick); 1398 1380 1399 if(client->state == WD_CLIENT_STATE_LOGGED_IN) { 1400 wd_broadcast_lock(); 1381 if(client->state == WD_CLIENT_STATE_LOGGED_IN) 1401 1382 wd_client_broadcast_status(client); 1402 wd_broadcast_unlock();1403 }1404 1383 } 1405 1384 } … … 1637 1616 count = wi_array_count(array); 1638 1617 1639 wd_broadcast_lock();1640 1618 for(i = 0; i < count; i++) { 1641 1619 string = WI_ARRAY(array, i); 1642 1620 1643 1621 if(wi_string_length(string) > 0) { 1644 wd_broadcast(c id, 300, WI_STR("%u%c%u%c%#@"),1622 wd_broadcast(chat, 300, WI_STR("%u%c%u%c%#@"), 1645 1623 cid, WD_FIELD_SEPARATOR, 1646 1624 client->uid, WD_FIELD_SEPARATOR, … … 1648 1626 } 1649 1627 } 1650 wd_broadcast_unlock();1651 1628 } 1652 1629 … … 1709 1686 client->status = wi_retain(status); 1710 1687 1711 if(client->state == WD_CLIENT_STATE_LOGGED_IN) { 1712 wd_broadcast_lock(); 1688 if(client->state == WD_CLIENT_STATE_LOGGED_IN) 1713 1689 wd_client_broadcast_status(client); 1714 wd_broadcast_unlock();1715 }1716 1690 } 1717 1691 } … … 1747 1721 wd_chat_set_topic(chat, WI_ARRAY(arguments, 1)); 1748 1722 1749 wd_broadcast_lock();1750 1723 wd_chat_broadcast_topic(chat); 1751 wd_broadcast_unlock();1752 1724 } 1753 1725 wired/trunk/wired/news.c
r3779 r4402 133 133 } 134 134 135 wd_broadcast_lock(); 136 wd_broadcast(WD_PUBLIC_CID, 322, WI_STR("%#@"), post); 137 wd_broadcast_unlock(); 135 wd_broadcast(wd_public_chat, 322, WI_STR("%#@"), post); 138 136 139 137 end: wired/trunk/wired/server.c
r4401 r4402 108 108 continue; 109 109 110 /* set ports */110 /* create sockets */ 111 111 wi_address_set_port(address, wd_settings.port); 112 control_socket = wi_autorelease(wi_socket_init_with_address(wi_socket_alloc(), address, WI_SOCKET_TCP)); 113 112 114 wi_address_set_port(address, wd_settings.port + 1); 113 114 /* create sockets */115 control_socket = wi_autorelease(wi_socket_init_with_address(wi_socket_alloc(), address, WI_SOCKET_TCP));116 115 transfer_socket = wi_autorelease(wi_socket_init_with_address(wi_socket_alloc(), address, WI_SOCKET_TCP)); 117 116 … … 197 196 string = wi_date_iso8601_string(wd_start_date); 198 197 199 wd_broadcast_lock(); 200 wd_broadcast(WD_PUBLIC_CID, 200, WI_STR("%#@%c%#@%c%#@%c%#@%c%#@%c%u%c%llu"), 198 wd_broadcast(wd_public_chat, 200, WI_STR("%#@%c%#@%c%#@%c%#@%c%#@%c%u%c%llu"), 201 199 wd_server_version_string, WD_FIELD_SEPARATOR, 202 200 wd_protocol_version_string, WD_FIELD_SEPARATOR, … … 206 204 wd_files_unique_count, WD_FIELD_SEPARATOR, 207 205 wd_files_unique_size); 208 wd_broadcast_unlock();209 206 } 210 207 … … 482 479 483 480 484 #pragma mark - 485 486 void wd_broadcast(wd_cid_t cid, unsigned int n, wi_string_t *fmt, ...) { 481 void wd_broadcast(wd_chat_t *chat, unsigned int n, wi_string_t *fmt, ...) { 487 482 wi_enumerator_t *enumerator; 488 wd_chat_t *chat;489 483 wd_client_t *client; 490 484 wi_string_t *string; … … 495 489 va_end(ap); 496 490 497 chat = wd_chats_chat_with_cid(cid);491 wi_array_rdlock(chat->clients); 498 492 499 493 enumerator = wi_array_data_enumerator(chat->clients); … … 506 500 } 507 501 } 502 503 wi_array_unlock(chat->clients); 508 504 509 505 wi_release(string); 510 506 } 511 512 513 514 void wd_broadcast_lock(void) {515 wi_list_rdlock(wd_chats);516 }517 518 519 520 void wd_broadcast_unlock(void) {521 wi_list_unlock(wd_chats);522 }wired/trunk/wired/server.h
r3551 r4402 54 54 void wd_reply_error(void); 55 55 void wd_sreply(wi_socket_t *, unsigned int, wi_string_t *, ...); 56 57 void wd_broadcast(wd_cid_t, unsigned int, wi_string_t *, ...); 58 void wd_broadcast_lock(void); 59 void wd_broadcast_unlock(void); 56 void wd_broadcast(wd_chat_t *, unsigned int, wi_string_t *, ...); 60 57 61 58 wired/trunk/wired/trackers.c
r4401 r4402 80 80 81 81 82 static wi_ list_t *wd_trackers;82 static wi_array_t *wd_trackers; 83 83 84 84 static wi_timer_t *wd_trackers_register_timer; … … 101 101 wd_tracker_runtime_id = wi_runtime_register_class(&wd_tracker_runtime_class); 102 102 103 wd_trackers = wi_ list_init(wi_list_alloc());103 wd_trackers = wi_array_init(wi_array_alloc()); 104 104 105 105 wd_trackers_register_timer = … … 126 126 uint32_t port; 127 127 128 wi_ list_wrlock(wd_trackers);129 wi_ list_remove_all_data(wd_trackers);128 wi_array_wrlock(wd_trackers); 129 wi_array_remove_all_data(wd_trackers); 130 130 131 131 enumerator = wi_array_data_enumerator(wd_settings.tracker); 132 132 133 133 while((string = wi_enumerator_next_data(enumerator))) { 134 tracker = w d_tracker_init(wd_tracker_alloc());135 url = wi_ url_init_with_string(wi_url_alloc(), string);134 tracker = wi_autorelease(wd_tracker_init(wd_tracker_alloc())); 135 url = wi_autorelease(wi_url_init_with_string(wi_url_alloc(), string)); 136 136 137 137 if(!wi_url_is_valid(url)) { … … 139 139 string); 140 140 141 goto next;141 continue; 142 142 } 143 143 … … 147 147 wi_log_warn(WI_STR("Could not set SSL context: %m")); 148 148 149 goto next;149 continue; 150 150 } 151 151 … … 162 162 wi_log_warn(WI_STR("Could not resolve \"%@\": %m"), tracker->host); 163 163 164 goto next;164 continue; 165 165 } 166 166 … … 175 175 wi_address_set_port(address, port); 176 176 177 wi_list_append_data(wd_trackers, tracker); 178 179 next: 180 wi_release(tracker); 181 wi_release(url); 182 } 183 184 wi_list_unlock(wd_trackers); 177 wi_array_add_data(wd_trackers, tracker); 178 } 179 180 wi_array_unlock(wd_trackers); 185 181 } 186 182 … … 259 255 260 256 void wd_trackers_register(wi_boolean_t update) { 261 if(wi_ list_count(wd_trackers) > 0) {257 if(wi_array_count(wd_trackers) > 0) { 262 258 wi_release(wd_trackers_guest_account); 263 259 … … 275 271 static void wd_trackers_register_thread(wi_runtime_instance_t *argument) { 276 272 wi_pool_t *pool; 273 wi_enumerator_t *enumerator; 277 274 wi_number_t *number = argument; 278 wi_list_node_t *node;279 275 wd_tracker_t *tracker; 280 276 wi_boolean_t update; … … 283 279 update = wi_number_bool(number); 284 280 285 wi_list_rdlock(wd_trackers); 286 WI_LIST_FOREACH(wd_trackers, node, tracker) { 281 wi_array_rdlock(wd_trackers); 282 283 enumerator = wi_array_data_enumerator(wd_trackers); 284 285 while((tracker = wi_enumerator_next_data(enumerator))) { 287 286 wd_tracker_register(tracker); 288 287 … … 290 289 wd_tracker_update(tracker); 291 290 } 292 wi_list_unlock(wd_trackers); 291 292 wi_array_unlock(wd_trackers); 293 293 294 294 if(update) … … 307 307 308 308 static void wd_trackers_update(void) { 309 wi_ list_node_t *node;309 wi_enumerator_t *enumerator; 310 310 wd_tracker_t *tracker; 311 311 312 wi_list_rdlock(wd_trackers); 313 WI_LIST_FOREACH(wd_trackers, node, tracker) { 312 wi_array_rdlock(wd_trackers); 313 314 enumerator = wi_array_data_enumerator(wd_trackers); 315 316 while((tracker = wi_enumerator_next_data(enumerator))) { 314 317 if(tracker->active) 315 318 wd_tracker_update(tracker); 316 319 } 317 wi_list_unlock(wd_trackers); 320 321 wi_array_unlock(wd_trackers); 318 322 } 319 323 … &hel
