[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-cvs-commits] wesnoth/src network_worker.cpp
From: |
David White |
Subject: |
[Wesnoth-cvs-commits] wesnoth/src network_worker.cpp |
Date: |
Fri, 29 Oct 2004 18:02:03 -0400 |
CVSROOT: /cvsroot/wesnoth
Module name: wesnoth
Branch:
Changes by: David White <address@hidden> 04/10/29 21:56:20
Modified files:
src : network_worker.cpp
Log message:
fixed threading bugs
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/network_worker.cpp.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
Patches:
Index: wesnoth/src/network_worker.cpp
diff -u wesnoth/src/network_worker.cpp:1.7 wesnoth/src/network_worker.cpp:1.8
--- wesnoth/src/network_worker.cpp:1.7 Sun Oct 17 21:38:05 2004
+++ wesnoth/src/network_worker.cpp Fri Oct 29 21:56:20 2004
@@ -43,8 +43,6 @@
int process_queue(void* data)
{
- threading::mutex m;
- const threading::lock mutex_lock(m);
LOG_NW << "thread started...\n";
for(;;) {
@@ -172,33 +170,32 @@
cond->notify_one();
}
-bool socket_locked(TCPsocket sock)
-{
- const threading::lock lock(*global_mutex);
- const socket_state_map::const_iterator i = sockets_locked.find(sock);
- if(i != sockets_locked.end()) {
- return i->second == SOCKET_LOCKED;
- } else {
- return false;
- }
-}
-
void close_socket(TCPsocket sock)
-{
- while(socket_locked(sock)) {
- SDL_Delay(10);
- }
-
- const threading::lock lock(*global_mutex);
- sockets_locked.erase(sock);
- std::multiset<buffer>::iterator i = bufs.begin();
- while(i != bufs.end()) {
- if(i->sock == sock) {
- bufs.erase(i++);
- } else {
- ++i;
- }
- }
+{
+ for(bool first_time = true; ; first_time = false) {
+ if(!first_time) {
+ SDL_Delay(10);
+ }
+
+ const threading::lock lock(*global_mutex);
+
+ const socket_state_map::iterator lock_it =
sockets_locked.find(sock);
+ if(lock_it != sockets_locked.end() && lock_it->second ==
SOCKET_LOCKED) {
+ continue;
+ } else if(lock_it != sockets_locked.end()) {
+ sockets_locked.erase(lock_it);
+ }
+
+ std::multiset<buffer>::iterator i = bufs.begin();
+ while(i != bufs.end()) {
+ if(i->sock == sock) {
+ bufs.erase(i++);
+ } else {
+ ++i;
+ }
+ }
+
+ }
}
TCPsocket detect_error()
- [Wesnoth-cvs-commits] wesnoth/src network_worker.cpp, Cedric Duval, 2004/10/12
- [Wesnoth-cvs-commits] wesnoth/src network_worker.cpp, David White, 2004/10/17
- [Wesnoth-cvs-commits] wesnoth/src network_worker.cpp, David White, 2004/10/17
- [Wesnoth-cvs-commits] wesnoth/src network_worker.cpp,
David White <=
- [Wesnoth-cvs-commits] wesnoth/src network_worker.cpp, David White, 2004/10/29
- [Wesnoth-cvs-commits] wesnoth/src network_worker.cpp, David White, 2004/10/29
- [Wesnoth-cvs-commits] wesnoth/src network_worker.cpp, Guillaume Melquiond, 2004/10/30