~ubuntu-branches/ubuntu/saucy/resiprocate/saucy-proposed

« back to all changes in this revision

Viewing changes to resip/stack/InterruptableStackThread.cxx

  • Committer: Package Import Robot
  • Author(s): Daniel Pocock
  • Date: 2012-05-17 19:29:59 UTC
  • Revision ID: package-import@ubuntu.com-20120517192959-vv00m77isztdy64q
Tags: upstream-1.8.2
ImportĀ upstreamĀ versionĀ 1.8.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "resip/stack/InterruptableStackThread.hxx"
 
2
#include "resip/stack/SipStack.hxx"
 
3
#include "resip/stack/SipMessage.hxx"
 
4
#include "rutil/SelectInterruptor.hxx"
 
5
#include "rutil/Logger.hxx"
 
6
 
 
7
#define RESIPROCATE_SUBSYSTEM Subsystem::SIP
 
8
 
 
9
using namespace resip;
 
10
 
 
11
InterruptableStackThread::InterruptableStackThread(SipStack& stack, SelectInterruptor& si)
 
12
   : mStack(stack),
 
13
     mSelectInterruptor(si)
 
14
{}
 
15
 
 
16
InterruptableStackThread::~InterruptableStackThread()
 
17
{
 
18
   //InfoLog (<< "InterruptableStackThread::~InterruptableStackThread()");
 
19
}
 
20
 
 
21
void
 
22
InterruptableStackThread::thread()
 
23
{
 
24
   while (!isShutdown())
 
25
   {
 
26
      try
 
27
      {
 
28
         FdSet fdset;
 
29
         mStack.process(fdset); // .dcm. reqd to get send requests queued at transports
 
30
         mSelectInterruptor.buildFdSet(fdset);
 
31
         mStack.buildFdSet(fdset);
 
32
         buildFdSet(fdset);
 
33
         int ret = fdset.selectMilliSeconds(resipMin(mStack.getTimeTillNextProcessMS(), 
 
34
                                                     getTimeTillNextProcessMS()));
 
35
         if (ret >= 0)
 
36
         {
 
37
            // .dlb. use return value to peak at the message to see if it is a
 
38
            // shutdown, and call shutdown if it is
 
39
            // .dcm. how will this interact w/ TuSelector?
 
40
            mSelectInterruptor.process(fdset);
 
41
            mStack.process(fdset);
 
42
            process(fdset);
 
43
         }
 
44
      }
 
45
      catch (BaseException& e)
 
46
      {
 
47
         ErrLog (<< "Unhandled exception: " << e);
 
48
      }
 
49
   }
 
50
   InfoLog (<< "Shutting down stack thread");
 
51
}
 
52
 
 
53
void
 
54
InterruptableStackThread::shutdown()
 
55
{
 
56
   ThreadIf::shutdown();
 
57
   mSelectInterruptor.interrupt();
 
58
}
 
59
 
 
60
void
 
61
InterruptableStackThread::buildFdSet(FdSet& fdset)
 
62
{
 
63
}
 
64
 
 
65
unsigned int
 
66
InterruptableStackThread::getTimeTillNextProcessMS() const
 
67
{
 
68
   //.dcm. --- eventually make infinite
 
69
   return 10000;   
 
70
}
 
71
 
 
72
void 
 
73
InterruptableStackThread::process(FdSet& fdset)
 
74
{
 
75
}
 
76
 
 
77
/* ====================================================================
 
78
 * The Vovida Software License, Version 1.0 
 
79
 * 
 
80
 * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved.
 
81
 * 
 
82
 * Redistribution and use in source and binary forms, with or without
 
83
 * modification, are permitted provided that the following conditions
 
84
 * are met:
 
85
 * 
 
86
 * 1. Redistributions of source code must retain the above copyright
 
87
 *    notice, this list of conditions and the following disclaimer.
 
88
 * 
 
89
 * 2. Redistributions in binary form must reproduce the above copyright
 
90
 *    notice, this list of conditions and the following disclaimer in
 
91
 *    the documentation and/or other materials provided with the
 
92
 *    distribution.
 
93
 * 
 
94
 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
 
95
 *    and "Vovida Open Communication Application Library (VOCAL)" must
 
96
 *    not be used to endorse or promote products derived from this
 
97
 *    software without prior written permission. For written
 
98
 *    permission, please contact vocal@vovida.org.
 
99
 *
 
100
 * 4. Products derived from this software may not be called "VOCAL", nor
 
101
 *    may "VOCAL" appear in their name, without prior written
 
102
 *    permission of Vovida Networks, Inc.
 
103
 * 
 
104
 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
 
105
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 
106
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
 
107
 * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
 
108
 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
 
109
 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
 
110
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 
111
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 
112
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 
113
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
114
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
 
115
 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
 
116
 * DAMAGE.
 
117
 * 
 
118
 * ====================================================================
 
119
 * 
 
120
 * This software consists of voluntary contributions made by Vovida
 
121
 * Networks, Inc. and many individuals on behalf of Vovida Networks,
 
122
 * Inc.  For more information on Vovida Networks, Inc., please see
 
123
 * <http://www.vovida.org/>.
 
124
 *
 
125
 */