|
reSIProcate/stack
9694
|
00001 00002 #if defined(HAVE_CONFIG_H) 00003 #include "config.h" 00004 #endif 00005 00006 #include <cassert> 00007 #include <limits.h> 00008 00009 #include "resip/stack/TimerQueue.hxx" 00010 #include "resip/stack/TimerMessage.hxx" 00011 #include "resip/stack/TransactionMessage.hxx" 00012 #include "resip/stack/TuSelector.hxx" 00013 #include "rutil/Logger.hxx" 00014 #include "rutil/Inserter.hxx" 00015 #include "rutil/WinLeakCheck.hxx" 00016 00017 using namespace resip; 00018 using namespace std; 00019 00020 #define RESIPROCATE_SUBSYSTEM Subsystem::TRANSACTION 00021 00022 TransactionTimerQueue::TransactionTimerQueue(Fifo<TimerMessage>& fifo) 00023 : mFifo(fifo) 00024 { 00025 } 00026 00027 #ifdef USE_DTLS 00028 00029 DtlsTimerQueue::DtlsTimerQueue( Fifo<DtlsMessage>& fifo ) 00030 : mFifo( fifo ) 00031 { 00032 } 00033 00034 #endif 00035 00036 UInt64 00037 TransactionTimerQueue::add(Timer::Type type, const Data& transactionId, unsigned long msOffset) 00038 { 00039 TransactionTimer t(msOffset, type, transactionId); 00040 mTimers.push(t); 00041 DebugLog (<< "Adding timer: " << Timer::toData(type) << " tid=" << transactionId << " ms=" << msOffset); 00042 return mTimers.top().getWhen(); 00043 } 00044 00045 #ifdef USE_DTLS 00046 00047 UInt64 00048 DtlsTimerQueue::add( SSL *ssl, unsigned long msOffset ) 00049 { 00050 TimerWithPayload t( msOffset, new DtlsMessage( ssl ) ) ; 00051 mTimers.push( t ) ; 00052 return mTimers.top().getWhen(); 00053 } 00054 00055 #endif 00056 00057 UInt64 00058 BaseTimeLimitTimerQueue::add(unsigned int timeMs,Message* payload) 00059 { 00060 assert(payload); 00061 DebugLog(<< "Adding application timer: " << payload->brief() << " ms=" << timeMs); 00062 mTimers.push(TimerWithPayload(timeMs,payload)); 00063 return mTimers.top().getWhen(); 00064 } 00065 00066 void 00067 BaseTimeLimitTimerQueue::processTimer(const TimerWithPayload& timer) 00068 { 00069 assert(timer.getMessage()); 00070 addToFifo(timer.getMessage(), TimeLimitFifo<Message>::InternalElement); 00071 } 00072 00073 void 00074 TransactionTimerQueue::processTimer(const TransactionTimer& timer) 00075 { 00076 mFifo.add(new TimerMessage(timer.getTransactionId(), 00077 timer.getType(), 00078 timer.getDuration())); 00079 } 00080 00081 TimeLimitTimerQueue::TimeLimitTimerQueue(TimeLimitFifo<Message>& fifo) : mFifo(fifo) 00082 {} 00083 00084 void 00085 TimeLimitTimerQueue::addToFifo(Message*msg, TimeLimitFifo<Message>::DepthUsage d) 00086 { 00087 mFifo.add(msg, d); 00088 } 00089 00090 TuSelectorTimerQueue::TuSelectorTimerQueue(TuSelector& sel) : mFifoSelector(sel) 00091 {} 00092 00093 UInt64 00094 TuSelectorTimerQueue::add(unsigned int timeMs,Message* payload) 00095 { 00096 assert(payload); 00097 DebugLog(<< "Adding application timer: " << payload->brief() << " ms=" << timeMs); 00098 mTimers.push(TimerWithPayload(timeMs,payload)); 00099 return mTimers.top().getWhen(); 00100 } 00101 00102 void 00103 TuSelectorTimerQueue::processTimer(const TimerWithPayload& timer) 00104 { 00105 mFifoSelector.add(timer.getMessage(), 00106 TimeLimitFifo<Message>::InternalElement); 00107 } 00108 00109 #ifdef USE_DTLS 00110 00111 void 00112 DtlsTimerQueue::processTimer(const TimerWithPayload& timer) 00113 { 00114 mFifo.add( (DtlsMessage *)timer.getMessage() ) ; 00115 } 00116 00117 #endif 00118 00119 /* ==================================================================== 00120 * The Vovida Software License, Version 1.0 00121 * 00122 * Copyright (c) 2004 Vovida Networks, Inc. All rights reserved. 00123 * 00124 * Redistribution and use in source and binary forms, with or without 00125 * modification, are permitted provided that the following conditions 00126 * are met: 00127 * 00128 * 1. Redistributions of source code must retain the above copyright 00129 * notice, this list of conditions and the following disclaimer. 00130 * 00131 * 2. Redistributions in binary form must reproduce the above copyright 00132 * notice, this list of conditions and the following disclaimer in 00133 * the documentation and/or other materials provided with the 00134 * distribution. 00135 * 00136 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 00137 * and "Vovida Open Communication Application Library (VOCAL)" must 00138 * not be used to endorse or promote products derived from this 00139 * software without prior written permission. For written 00140 * permission, please contact vocal@vovida.org. 00141 * 00142 * 4. Products derived from this software may not be called "VOCAL", nor 00143 * may "VOCAL" appear in their name, without prior written 00144 * permission of Vovida Networks, Inc. 00145 * 00146 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00147 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00148 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 00149 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 00150 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 00151 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 00152 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00153 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00154 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00155 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00156 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00157 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00158 * DAMAGE. 00159 * 00160 * ==================================================================== 00161 * 00162 * This software consists of voluntary contributions made by Vovida 00163 * Networks, Inc. and many individuals on behalf of Vovida Networks, 00164 * Inc. For more information on Vovida Networks, Inc., please see 00165 * <http://www.vovida.org/>. 00166 * 00167 */
1.7.5.1