| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 kTraceTransport, | 177 kTraceTransport, |
| 178 _id, | 178 _id, |
| 179 "UdpSocketManagerPosix(%d)::RemoveSocket() failed to remove socket\ | 179 "UdpSocketManagerPosix(%d)::RemoveSocket() failed to remove socket\ |
| 180 from manager", | 180 from manager", |
| 181 _numberOfSocketMgr); | 181 _numberOfSocketMgr); |
| 182 } | 182 } |
| 183 _critSect->Leave(); | 183 _critSect->Leave(); |
| 184 return retVal; | 184 return retVal; |
| 185 } | 185 } |
| 186 | 186 |
| 187 | |
| 188 UdpSocketManagerPosixImpl::UdpSocketManagerPosixImpl() | 187 UdpSocketManagerPosixImpl::UdpSocketManagerPosixImpl() |
| 189 { | 188 : _thread(UdpSocketManagerPosixImpl::Run, |
| 190 _critSectList = CriticalSectionWrapper::CreateCriticalSection(); | 189 this, |
| 191 _thread = PlatformThread::CreateThread(UdpSocketManagerPosixImpl::Run, this, | 190 "UdpSocketManagerPosixImplThread"), |
| 192 "UdpSocketManagerPosixImplThread"); | 191 _critSectList(CriticalSectionWrapper::CreateCriticalSection()) { |
| 193 FD_ZERO(&_readFds); | 192 FD_ZERO(&_readFds); |
| 194 WEBRTC_TRACE(kTraceMemory, kTraceTransport, -1, | 193 WEBRTC_TRACE(kTraceMemory, kTraceTransport, -1, |
| 195 "UdpSocketManagerPosix created"); | 194 "UdpSocketManagerPosix created"); |
| 196 } | 195 } |
| 197 | 196 |
| 198 UdpSocketManagerPosixImpl::~UdpSocketManagerPosixImpl() | 197 UdpSocketManagerPosixImpl::~UdpSocketManagerPosixImpl() |
| 199 { | 198 { |
| 200 if (_critSectList != NULL) | 199 if (_critSectList != NULL) |
| 201 { | 200 { |
| 202 UpdateSocketMap(); | 201 UpdateSocketMap(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 213 | 212 |
| 214 delete _critSectList; | 213 delete _critSectList; |
| 215 } | 214 } |
| 216 | 215 |
| 217 WEBRTC_TRACE(kTraceMemory, kTraceTransport, -1, | 216 WEBRTC_TRACE(kTraceMemory, kTraceTransport, -1, |
| 218 "UdpSocketManagerPosix deleted"); | 217 "UdpSocketManagerPosix deleted"); |
| 219 } | 218 } |
| 220 | 219 |
| 221 bool UdpSocketManagerPosixImpl::Start() | 220 bool UdpSocketManagerPosixImpl::Start() |
| 222 { | 221 { |
| 223 if (!_thread) | |
| 224 { | |
| 225 return false; | |
| 226 } | |
| 227 | |
| 228 WEBRTC_TRACE(kTraceStateInfo, kTraceTransport, -1, | 222 WEBRTC_TRACE(kTraceStateInfo, kTraceTransport, -1, |
| 229 "Start UdpSocketManagerPosix"); | 223 "Start UdpSocketManagerPosix"); |
| 230 if (!_thread->Start()) | 224 _thread.Start(); |
| 231 return false; | 225 _thread.SetPriority(rtc::kRealtimePriority); |
| 232 _thread->SetPriority(kRealtimePriority); | |
| 233 return true; | 226 return true; |
| 234 } | 227 } |
| 235 | 228 |
| 236 bool UdpSocketManagerPosixImpl::Stop() | 229 bool UdpSocketManagerPosixImpl::Stop() |
| 237 { | 230 { |
| 238 if (!_thread) | |
| 239 { | |
| 240 return true; | |
| 241 } | |
| 242 | |
| 243 WEBRTC_TRACE(kTraceStateInfo, kTraceTransport, -1, | 231 WEBRTC_TRACE(kTraceStateInfo, kTraceTransport, -1, |
| 244 "Stop UdpSocketManagerPosix"); | 232 "Stop UdpSocketManagerPosix"); |
| 245 return _thread->Stop(); | 233 _thread.Stop(); |
| 234 return true; |
| 246 } | 235 } |
| 247 | 236 |
| 248 bool UdpSocketManagerPosixImpl::Process() | 237 bool UdpSocketManagerPosixImpl::Process() |
| 249 { | 238 { |
| 250 bool doSelect = false; | 239 bool doSelect = false; |
| 251 // Timeout = 1 second. | 240 // Timeout = 1 second. |
| 252 struct timeval timeout; | 241 struct timeval timeout; |
| 253 timeout.tv_sec = 0; | 242 timeout.tv_sec = 0; |
| 254 timeout.tv_usec = 10000; | 243 timeout.tv_usec = 10000; |
| 255 | 244 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 if(s) { | 383 if(s) { |
| 395 _socketMap[s->GetFd()] = s; | 384 _socketMap[s->GetFd()] = s; |
| 396 } | 385 } |
| 397 } | 386 } |
| 398 _addList.clear(); | 387 _addList.clear(); |
| 399 _critSectList->Leave(); | 388 _critSectList->Leave(); |
| 400 } | 389 } |
| 401 | 390 |
| 402 } // namespace test | 391 } // namespace test |
| 403 } // namespace webrtc | 392 } // namespace webrtc |
| OLD | NEW |