/[resiprocate]/main/resip/dum/ServerPagerMessage.cxx
ViewVC logotype

Contents of /main/resip/dum/ServerPagerMessage.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 9956 - (show annotations) (download)
Sat Jan 26 02:05:35 2013 UTC (6 years, 9 months ago) by fjoanis
File MIME type: text/plain
File size: 6831 byte(s)
- Ensured that all DUM usages/sessions DumCommandAdapter commands are using handles rather than references when saving the usage/session they apply to.
 - This fixes potential crashes in the case where a DumCommandAdapter would be enqueued onto the stack's queue while a usage terminating message is sitting in the queue.
 - The effect in that case would be that the saved reference to the usage would become invalid and this could cause a crash.
- Also fixed an issue with InviteSession::*NITCommand() where DumCommandAdapter commands would end up being recursively queued onto the stack.

1 #include "resip/stack/SipMessage.hxx"
2 #include "resip/stack/MethodTypes.hxx"
3 #include "resip/dum/ServerPagerMessage.hxx"
4 #include "resip/dum/OutOfDialogHandler.hxx"
5 #include "resip/dum/DialogUsageManager.hxx"
6 #include "resip/dum/Dialog.hxx"
7 #include "resip/dum/PagerMessageHandler.hxx"
8 #include "rutil/Logger.hxx"
9 #include "rutil/WinLeakCheck.hxx"
10
11 using namespace resip;
12
13 #define RESIPROCATE_SUBSYSTEM Subsystem::DUM
14
15 ServerPagerMessageHandle
16 ServerPagerMessage::getHandle()
17 {
18 return ServerPagerMessageHandle(mDum, getBaseHandle().getId());
19 }
20
21 ServerPagerMessage::ServerPagerMessage(DialogUsageManager& dum,
22 DialogSet& dialogSet,
23 const SipMessage& req) :
24 NonDialogUsage(dum, dialogSet),
25 mRequest(req),
26 mResponse(new SipMessage)
27 {
28 }
29
30 ServerPagerMessage::~ServerPagerMessage()
31 {
32 mDialogSet.mServerPagerMessage = 0;
33 }
34
35
36 void
37 ServerPagerMessage::end()
38 {
39 delete this;
40 }
41
42 class ServerPagerMessageEndCommand : public DumCommandAdapter
43 {
44 public:
45 ServerPagerMessageEndCommand(const ServerPagerMessageHandle& serverPagerMessageHandle)
46 : mServerPagerMessageHandle(serverPagerMessageHandle)
47 {
48
49 }
50
51 virtual void executeCommand()
52 {
53 if(mServerPagerMessageHandle.isValid())
54 {
55 mServerPagerMessageHandle->end();
56 }
57 }
58
59 virtual EncodeStream& encodeBrief(EncodeStream& strm) const
60 {
61 return strm << "ServerPagerMessageEndCommand";
62 }
63 private:
64 ServerPagerMessageHandle mServerPagerMessageHandle;
65 };
66
67 void ServerPagerMessage::endCommand()
68 {
69 mDum.post(new ServerPagerMessageEndCommand(getHandle()));
70 }
71
72 void
73 ServerPagerMessage::dispatch(const SipMessage& msg)
74 {
75 assert(msg.isRequest());
76 ServerPagerMessageHandler* handler = mDum.mServerPagerMessageHandler;
77
78 //?dcm? check in DialogUsageManager
79 if (!handler)
80 {
81 mDum.makeResponse(*mResponse, msg, 405);
82 mDum.send(mResponse);
83 delete this;
84 return;
85 }
86 handler->onMessageArrived(getHandle(), msg);
87 }
88
89 void
90 ServerPagerMessage::dispatch(const DumTimeout& msg)
91 {
92 }
93
94 void
95 ServerPagerMessage::send(SharedPtr<SipMessage> response)
96 {
97 assert(response->isResponse());
98 mDum.send(response);
99 delete this;
100 }
101
102 SharedPtr<SipMessage>
103 ServerPagerMessage::accept(int statusCode)
104 {
105 //!dcm! -- should any responses include a contact?
106 mDum.makeResponse(*mResponse, mRequest, statusCode);
107 mResponse->remove(h_Contacts);
108 return mResponse;
109 }
110
111 class ServerPagerMessageAcceptCommand : public DumCommandAdapter
112 {
113 public:
114 ServerPagerMessageAcceptCommand(const ServerPagerMessageHandle& serverPagerMessageHandle, int statusCode)
115 : mServerPagerMessageHandle(serverPagerMessageHandle),
116 mStatusCode(statusCode)
117 {
118 }
119
120 virtual void executeCommand()
121 {
122 if(mServerPagerMessageHandle.isValid())
123 {
124 mServerPagerMessageHandle->accept(mStatusCode);
125 }
126 }
127
128 virtual EncodeStream& encodeBrief(EncodeStream& strm) const
129 {
130 return strm << "ServerPagerMessageAcceptCommand";
131 }
132 private:
133 ServerPagerMessageHandle mServerPagerMessageHandle;
134 int mStatusCode;
135 };
136
137 void
138 ServerPagerMessage::acceptCommand(int statusCode)
139 {
140 mDum.post(new ServerPagerMessageAcceptCommand(getHandle(), statusCode));
141 }
142
143 SharedPtr<SipMessage>
144 ServerPagerMessage::reject(int statusCode)
145 {
146 //!dcm! -- should any responses include a contact?
147 mDum.makeResponse(*mResponse, mRequest, statusCode);
148 return mResponse;
149 }
150
151 class ServerPagerMessageRejectCommand : public DumCommandAdapter
152 {
153 public:
154 ServerPagerMessageRejectCommand(const ServerPagerMessageHandle& serverPagerMessageHandle, int statusCode)
155 : mServerPagerMessageHandle(serverPagerMessageHandle),
156 mStatusCode(statusCode)
157 {
158 }
159
160 virtual void executeCommand()
161 {
162 if(mServerPagerMessageHandle.isValid())
163 {
164 mServerPagerMessageHandle->reject(mStatusCode);
165 }
166 }
167
168 virtual EncodeStream& encodeBrief(EncodeStream& strm) const
169 {
170 return strm << "ServerPagerMessageRejectCommand";
171 }
172 private:
173 ServerPagerMessageHandle mServerPagerMessageHandle;
174 int mStatusCode;
175 };
176
177 void
178 ServerPagerMessage::rejectCommand(int statusCode)
179 {
180 mDum.post(new ServerPagerMessageRejectCommand(getHandle(), statusCode));
181 }
182
183 EncodeStream&
184 ServerPagerMessage::dump(EncodeStream& strm) const
185 {
186 strm << "ServerPagerMessage ";
187 mRequest.encodeBrief(strm);
188 return strm;
189 }
190
191
192
193 /* ====================================================================
194 * The Vovida Software License, Version 1.0
195 *
196 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
197 *
198 * Redistribution and use in source and binary forms, with or without
199 * modification, are permitted provided that the following conditions
200 * are met:
201 *
202 * 1. Redistributions of source code must retain the above copyright
203 * notice, this list of conditions and the following disclaimer.
204 *
205 * 2. Redistributions in binary form must reproduce the above copyright
206 * notice, this list of conditions and the following disclaimer in
207 * the documentation and/or other materials provided with the
208
209 * distribution.
210 *
211 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
212 * and "Vovida Open Communication Application Library (VOCAL)" must
213 * not be used to endorse or promote products derived from this
214 * software without prior written permission. For written
215 * permission, please contact vocal@vovida.org.
216 *
217 * 4. Products derived from this software may not be called "VOCAL", nor
218 * may "VOCAL" appear in their name, without prior written
219 * permission of Vovida Networks, Inc.
220 *
221 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
222 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
223 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
224 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
225 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
226 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
227 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
228 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
229 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
230 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
231 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
232 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
233 * DAMAGE.
234 *
235 * ====================================================================
236 *
237 * This software consists of voluntary contributions made by Vovida
238 * Networks, Inc. and many individuals on behalf of Vovida Networks,
239 * Inc. For more information on Vovida Networks, Inc., please see
240 * <http://www.vovida.org/>.
241 *
242 */

Properties

Name Value
svn:eol-style native
svn:mime-type text/plain

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27