From: Matze B. <mat...@us...> - 2002-03-12 17:24:47
|
Update of /cvsroot/planeshift/planeshift/src/common/net In directory usw-pr-cvs1:/tmp/cvs-serv26140/src/common/net Modified Files: msghandler.cpp msghandler.h Log Message: msghandler is threadsafe now Index: msghandler.cpp =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/common/net/msghandler.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** msghandler.cpp 8 Mar 2002 17:45:46 -0000 1.16 --- msghandler.cpp 12 Mar 2002 17:11:35 -0000 1.17 *************** *** 61,64 **** --- 61,65 ---- void MsgHandler::Publish(MsgEntry* me) { + lock.enter(); Subscription *first = (Subscription*) subscribers.GetFirstItem(); Subscription *p = first; *************** *** 75,78 **** --- 76,80 ---- p = (Subscription*) subscribers.GetNextItem(); } while (p != first); + lock.leave(); } *************** *** 83,91 **** p->subscriber = subscriber; p->who = client; ! p->type = type; // TODO: Should check for duplicates here at some point. KWF ! subscribers.AddItem(p); return true; --- 85,94 ---- p->subscriber = subscriber; p->who = client; ! p->type = type; // TODO: Should check for duplicates here at some point. KWF ! lock.enter(); subscribers.AddItem(p); + lock.leave(); return true; *************** *** 94,97 **** --- 97,101 ---- bool MsgHandler::Unsubscribe(iNetSubscriber *subscriber, msgtype type, uint32_t client) { + lock.enter(); Subscription* first = (Subscription*) subscribers.GetFirstItem(); Subscription* p = first; *************** *** 105,108 **** --- 109,113 ---- { subscribers.RemoveItem((void*) p); + lock.leave(); return true; } *************** *** 110,113 **** --- 115,119 ---- } while (p != first); + lock.leave(); return false; } *************** *** 131,135 **** while( (msg=This->queue->GetWait()) ) { ! This->Publish(msg); task::sleep(100); } --- 137,141 ---- while( (msg=This->queue->GetWait()) ) { ! This->Publish(msg); task::sleep(100); } Index: msghandler.h =================================================================== RCS file: /cvsroot/planeshift/planeshift/src/common/net/msghandler.h,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** msghandler.h 8 Mar 2002 17:45:46 -0000 1.16 --- msghandler.h 12 Mar 2002 17:11:36 -0000 1.17 *************** *** 94,97 **** --- 94,98 ---- MsgQueue *queue; csDLinkList subscribers; + mutex lock; }; |