Changeset 10941 for trunk/FACT++/src
- Timestamp:
- 06/09/11 10:47:58 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/MessageDim.cc
r10919 r10941 68 68 int MessageDimTX::Write(const Time &t, const string &txt, int qos) 69 69 { 70 static mutex mtx;70 MessageImp::Write(t, txt, qos); 71 71 72 mtx.lock();73 72 74 MessageImp::Write(t, txt, qos); 73 // We cannot use our own mutex here because it can create dead-locks 74 // in a hand-shake with the global dim-mutex if a service is 75 // updated from within a dimHandler (dim-mutex already locked) 76 // and at the same time another thread tries to lock the mutex. 77 // 78 // Thread 1: Lock global Dim mutex and call infoHandler 79 // 80 // Thread 2: CALL Write 81 // Thread 2: LOCK Write-mutex 82 // Thread 2: setQuality will try to lock global Dim mutex 83 // (since Thread1!=Thread2 this results in a wait) 84 // 85 // Thread 1: CALL Write from within the infoHandler 86 // Thread 1: LOCK Write-mutex 87 // (since Thread2 now waits for the infoHandler to finish 88 // and the infoHandler has to wait for the Write-mutex 89 // we have a dead-lock) 90 // 91 extern void dim_lock(); 92 extern void dim_unlock(); 93 94 dim_lock(); 75 95 76 96 // We have to use setData to make sure the DimService will 77 97 // hold a local copy of the data. 98 setData(const_cast<char*>(txt.c_str())); 78 99 setQuality(qos); 79 setData(const_cast<char*>(txt.c_str())); 100 80 101 const int rc = updateService(); 102 103 dim_unlock(); 81 104 82 105 if (rc==0 && fDebug) 83 106 Out() << " !! " << t.GetAsStr() << " - Sending failed!" << endl; 84 85 mtx.unlock();86 107 87 108 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.