/[resiprocate]/branches/b-directory-reorg/sip/resiprocate/TransactionController.cxx
ViewVC logotype

Contents of /branches/b-directory-reorg/sip/resiprocate/TransactionController.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5271 - (show annotations) (download)
Thu Aug 18 23:43:07 2005 UTC (14 years, 3 months ago) by jason
File size: 6106 byte(s)
new directory reorg proposal
1 #if defined(HAVE_CONFIG_H)
2 #include "resiprocate/config.hxx"
3 #endif
4
5 #include "resiprocate/ApplicationMessage.hxx"
6 #include "resiprocate/ShutdownMessage.hxx"
7 #include "resiprocate/SipMessage.hxx"
8 #include "resiprocate/TransactionController.hxx"
9 #include "resiprocate/TransactionState.hxx"
10 #include "resiprocate/os/Logger.hxx"
11 #include "resiprocate/os/WinLeakCheck.hxx"
12 #include "resiprocate/SipStack.hxx"
13
14 using namespace resip;
15
16 #define RESIPROCATE_SUBSYSTEM Subsystem::TRANSACTION
17
18 #if defined(WIN32)
19 #pragma warning( disable : 4355 ) // using this in base member initializer list
20 #endif
21
22 unsigned int TransactionController::MaxTUFifoSize = 0;
23 unsigned int TransactionController::MaxTUFifoTimeDepthSecs = 0;
24
25 TransactionController::TransactionController(SipStack& stack) :
26 mStack(stack),
27 mRegisteredForTransactionTermination(false),
28 mDiscardStrayResponses(true),
29 mStateMacFifo(),
30 mTuSelector(stack.mTuSelector),
31 mTransportSelector(mStateMacFifo, stack.getSecurity(), stack.getDnsStub()),
32 mTimers(mStateMacFifo),
33 mShuttingDown(false),
34 mStatsManager(stack.mStatsManager)
35 {
36 }
37
38 #if defined(WIN32)
39 #pragma warning( default : 4355 )
40 #endif
41
42 TransactionController::~TransactionController()
43 {
44 }
45
46
47 bool
48 TransactionController::isTUOverloaded() const
49 {
50 return !mTuSelector.wouldAccept(TimeLimitFifo<Message>::EnforceTimeDepth);
51 }
52
53 void
54 TransactionController::shutdown()
55 {
56 mShuttingDown = true;
57 mTransportSelector.shutdown();
58 }
59
60 void
61 TransactionController::process(FdSet& fdset)
62 {
63 if (mShuttingDown &&
64 //mTimers.empty() &&
65 !mStateMacFifo.messageAvailable() && // !dcm! -- see below
66 !mStack.mTUFifo.messageAvailable() &&
67 mTransportSelector.isFinished())
68 // !dcm! -- why would one wait for the Tu's fifo to be empty before delivering a
69 // shutdown message?
70 {
71 //!dcm! -- send to all?
72 mTuSelector.add(new ShutdownMessage, TimeLimitFifo<Message>::InternalElement);
73 }
74 else
75 {
76 mTransportSelector.process(fdset);
77 mTimers.process();
78
79 while (mStateMacFifo.messageAvailable())
80 {
81 TransactionState::process(*this);
82 }
83 }
84 }
85
86 unsigned int
87 TransactionController::getTimeTillNextProcessMS()
88 {
89 if ( mStateMacFifo.messageAvailable() )
90 {
91 return 0;
92 }
93 else if ( mTransportSelector.hasDataToSend() )
94 {
95 return 0;
96 }
97
98 return resipMin(mTimers.msTillNextTimer(), mTransportSelector.getTimeTillNextProcessMS());
99 }
100
101 void
102 TransactionController::buildFdSet( FdSet& fdset)
103 {
104 mTransportSelector.buildFdSet( fdset );
105 }
106
107 void
108 TransactionController::send(SipMessage* msg)
109 {
110 mStateMacFifo.add(msg);
111 }
112
113 void
114 TransactionController::registerForTransactionTermination()
115 {
116 mRegisteredForTransactionTermination = true;
117 }
118
119 unsigned int
120 TransactionController::getTuFifoSize() const
121 {
122 return mTuSelector.size();
123 }
124
125 unsigned int
126 TransactionController::sumTransportFifoSizes() const
127 {
128 return mTransportSelector.sumTransportFifoSizes();
129 }
130
131 unsigned int
132 TransactionController::getTransactionFifoSize() const
133 {
134 return mStateMacFifo.size();
135 }
136
137 unsigned int
138 TransactionController::getNumClientTransactions() const
139 {
140 return mClientTransactionMap.size();
141 }
142
143 unsigned int
144 TransactionController::getNumServerTransactions() const
145 {
146 return mServerTransactionMap.size();
147 }
148
149 unsigned int
150 TransactionController::getTimerQueueSize() const
151 {
152 return mTimers.size();
153 }
154
155 void
156 TransactionController::registerBlacklistListener(int rrType, DnsStub::BlacklistListener* l)
157 {
158 mTransportSelector.registerBlacklistListener(rrType, l);
159 }
160
161 void TransactionController::unregisterBlacklistListener(int rrType, DnsStub::BlacklistListener* l)
162 {
163 mTransportSelector.unregisterBlacklistListener(rrType, l);
164 }
165
166
167 /* ====================================================================
168 * The Vovida Software License, Version 1.0
169 *
170 * Copyright (c) 2004 Vovida Networks, Inc. All rights reserved.
171 *
172 * Redistribution and use in source and binary forms, with or without
173 * modification, are permitted provided that the following conditions
174 * are met:
175 *
176 * 1. Redistributions of source code must retain the above copyright
177 * notice, this list of conditions and the following disclaimer.
178 *
179 * 2. Redistributions in binary form must reproduce the above copyright
180 * notice, this list of conditions and the following disclaimer in
181 * the documentation and/or other materials provided with the
182 * distribution.
183 *
184 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
185 * and "Vovida Open Communication Application Library (VOCAL)" must
186 * not be used to endorse or promote products derived from this
187 * software without prior written permission. For written
188 * permission, please contact vocal@vovida.org.
189 *
190 * 4. Products derived from this software may not be called "VOCAL", nor
191 * may "VOCAL" appear in their name, without prior written
192 * permission of Vovida Networks, Inc.
193 *
194 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
195 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
196 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
197 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
198 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
199 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
200 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
201 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
202 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
203 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
204 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
205 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
206 * DAMAGE.
207 *
208 * ====================================================================
209 *
210 * This software consists of voluntary contributions made by Vovida
211 * Networks, Inc. and many individuals on behalf of Vovida Networks,
212 * Inc. For more information on Vovida Networks, Inc., please see
213 * <http://www.vovida.org/>.
214 *
215 */

Properties

Name Value
svn:eol-style LF

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27