This file is indexed.

/usr/include/resip/stack/TimerQueue.hxx is in libresiprocate-1.9-dev 1.9.6-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
#if !defined(RESIP_TIMERQUEUE_HXX)
#define RESIP_TIMERQUEUE_HXX 

#if defined(HAVE_CONFIG_H)
  #include "config.h"
#endif

#include <functional>
#include <queue>
#include <set>
#include <iosfwd>
#include "resip/stack/TimerMessage.hxx"
#include "resip/stack/DtlsMessage.hxx"
#include "rutil/Fifo.hxx"
#include "rutil/TimeLimitFifo.hxx"
#include "rutil/Timer.hxx"

// .dlb. 
// to do: timer wheel for transaction-bound timers and a heap for
// everything longer.

namespace resip
{

class Message;
class TransactionMessage;
class TuSelector;

/**
  * @internal
  * @brief This class takes a fifo as a place to where you can write your stuff.
  * When using this in the main loop, call process() on this.
  * During Transaction processing, TimerMessages and SIP messages are generated.
  * 
    @todo .dlb. timer wheel for transaction-bound timers and a heap for 
      everything longer.
  */
template <class T>
class TimerQueue
{
   public:
      // This is the logic that runs when a timer goes off. This is the only
      // thing subclasses must implement.
      virtual void processTimer(const T& timer)=0;

      /// @brief deletes the message associated with the timer as well.
      virtual ~TimerQueue()
      {
         //xkd-2004-11-4
         // delete the message associated with the timer
         while (!mTimers.empty())
         {
            mTimers.pop();
         }
      }

      /// @brief provides the time in milliseconds before the next timer will fire
      ///  @retval milliseconds time until the next timer will fire
      ///  @retval 0 implies that timers occur in the past
      /// @retval INT_MAX implies that there are no timers
      ///
      unsigned int msTillNextTimer()
      {
         if (!mTimers.empty())
         {
            UInt64 next = mTimers.top().getWhen();
            UInt64 now = Timer::getTimeMs();
            if (now > next) 
            {
               return 0;
            }
            else
            {
               UInt64 ret64 = next - now;
               if ( ret64 > UInt64(INT_MAX) )
               {
                  return INT_MAX;
               }
               else
               { 
                  int ret = int(ret64);
                  return ret;
               }
            }
         }
         else
         {
            return INT_MAX;
         }
      }

      /// @brief gets the set of timers that have fired, and inserts TimerMsg into the state
      /// machine fifo and application messages into the TU fifo
      virtual UInt64 process()
      {
         if (!mTimers.empty())
         {
            UInt64 now=Timer::getTimeMs();
            while (!mTimers.empty() && !(mTimers.top().getWhen() > now))
            {
               processTimer(mTimers.top());
               mTimers.pop();
            }

            if(!mTimers.empty())
            {
               return mTimers.top().getWhen();
            }
         }
         return 0;
      }

      int size() const
      {
         return (int)mTimers.size();
      }

      bool empty() const
      {
         return mTimers.empty();
      }

      std::ostream& encode(std::ostream& str) const
      {
         if(mTimers.size() > 0)
         {
            return str << "TimerQueue[ size =" << mTimers.size() 
                       << " top=" << mTimers.top() << "]" ;
         }
         else
         {
            return str << "TimerQueue[ size = 0 ]";
         }
      }

#ifndef RESIP_USE_STL_STREAMS
      EncodeStream& encode(EncodeStream& str) const
      {
         if(mTimers.size() > 0)
         {
            return str << "TimerQueue[ size =" << mTimers.size() 
                       << " top=" << mTimers.top() << "]" ;
         }
         else
         {
            return str << "TimerQueue[ size = 0 ]";
         }
      }
#endif

   protected:
      typedef std::vector<T, std::allocator<T> > TimerVector;
      std::priority_queue<T, TimerVector, std::greater<T> > mTimers;
};

/**
   @internal
*/
class BaseTimeLimitTimerQueue : public TimerQueue<TimerWithPayload>
{
   public:
      ~BaseTimeLimitTimerQueue();
      UInt64 add(unsigned int timeMs,Message* payload);
      virtual void processTimer(const TimerWithPayload& timer);
   protected:
      virtual void addToFifo(Message*, TimeLimitFifo<Message>::DepthUsage)=0;      
};


/**
   @internal
*/
class TimeLimitTimerQueue : public BaseTimeLimitTimerQueue
{
   public:
      TimeLimitTimerQueue(TimeLimitFifo<Message>& fifo);
   protected:
      virtual void addToFifo(Message*, TimeLimitFifo<Message>::DepthUsage);
   private:
      TimeLimitFifo<Message>& mFifo;
};


/**
   @internal
*/
class TuSelectorTimerQueue : public TimerQueue<TimerWithPayload>
{
   public:
      TuSelectorTimerQueue(TuSelector& sel);
      ~TuSelectorTimerQueue();
      UInt64 add(unsigned int timeMs,Message* payload);
      virtual void processTimer(const TimerWithPayload& timer);
   private:
      TuSelector& mFifoSelector;
};


/**
   @internal
*/
class TransactionTimerQueue : public TimerQueue<TransactionTimer>
{
   public:
      TransactionTimerQueue(Fifo<TimerMessage>& fifo);
      UInt64 add(Timer::Type type, const Data& transactionId, unsigned long msOffset);
      virtual void processTimer(const TransactionTimer& timer);
   private:
      Fifo<TimerMessage>& mFifo;
};

#ifdef USE_DTLS

#include <openssl/ssl.h>

/**
   @internal
*/
class DtlsTimerQueue : public TimerQueue<TimerWithPayload>
{
   public:
      DtlsTimerQueue(Fifo<DtlsMessage>& fifo);
      ~DtlsTimerQueue();
      UInt64 add(SSL *, unsigned long msOffset);
      virtual void processTimer(const TimerWithPayload& timer) ;
      
   private:
      Fifo<DtlsMessage>& mFifo ;
};

#endif

template <class T>
std::ostream& operator<<(std::ostream& str, const TimerQueue<T>& tq)
{
   return tq.encode(str);
}

#ifndef RESIP_USE_STL_STREAMS
template <class T>
EncodeStream& operator<<(EncodeStream& str, const TimerQueue<T>& tq)
{
   return tq.encode(str);
}
#endif


}

#endif

/* ====================================================================
 * The Vovida Software License, Version 1.0 
 * 
 * Copyright (c) 2004 Vovida Networks, Inc.  All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 * 
 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
 *    and "Vovida Open Communication Application Library (VOCAL)" must
 *    not be used to endorse or promote products derived from this
 *    software without prior written permission. For written
 *    permission, please contact vocal@vovida.org.
 *
 * 4. Products derived from this software may not be called "VOCAL", nor
 *    may "VOCAL" appear in their name, without prior written
 *    permission of Vovida Networks, Inc.
 * 
 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
 * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
 * DAMAGE.
 * 
 * ====================================================================
 * 
 * This software consists of voluntary contributions made by Vovida
 * Networks, Inc. and many individuals on behalf of Vovida Networks,
 * Inc.  For more information on Vovida Networks, Inc., please see
 * <http://www.vovida.org/>.
 *
 */