|
reSIProcate/stack
9694
|
00001 #include "resip/stack/InterruptableStackThread.hxx" 00002 #include "resip/stack/SipStack.hxx" 00003 #include "resip/stack/SipMessage.hxx" 00004 #include "rutil/SelectInterruptor.hxx" 00005 #include "rutil/Logger.hxx" 00006 00007 #define RESIPROCATE_SUBSYSTEM Subsystem::SIP 00008 00009 using namespace resip; 00010 00011 InterruptableStackThread::InterruptableStackThread(SipStack& stack, SelectInterruptor& si) 00012 : mStack(stack), 00013 mSelectInterruptor(si) 00014 {} 00015 00016 InterruptableStackThread::~InterruptableStackThread() 00017 { 00018 //InfoLog (<< "InterruptableStackThread::~InterruptableStackThread()"); 00019 } 00020 00021 void 00022 InterruptableStackThread::thread() 00023 { 00024 while (!isShutdown()) 00025 { 00026 try 00027 { 00028 FdSet fdset; 00029 mStack.process(fdset); // .dcm. reqd to get send requests queued at transports 00030 mSelectInterruptor.buildFdSet(fdset); 00031 mStack.buildFdSet(fdset); 00032 buildFdSet(fdset); 00033 int ret = fdset.selectMilliSeconds(resipMin(mStack.getTimeTillNextProcessMS(), 00034 getTimeTillNextProcessMS())); 00035 if (ret >= 0) 00036 { 00037 // .dlb. use return value to peak at the message to see if it is a 00038 // shutdown, and call shutdown if it is 00039 // .dcm. how will this interact w/ TuSelector? 00040 mSelectInterruptor.process(fdset); 00041 mStack.process(fdset); 00042 process(fdset); 00043 } 00044 } 00045 catch (BaseException& e) 00046 { 00047 ErrLog (<< "Unhandled exception: " << e); 00048 } 00049 } 00050 InfoLog (<< "Shutting down stack thread"); 00051 } 00052 00053 void 00054 InterruptableStackThread::shutdown() 00055 { 00056 ThreadIf::shutdown(); 00057 mSelectInterruptor.interrupt(); 00058 } 00059 00060 void 00061 InterruptableStackThread::buildFdSet(FdSet& fdset) 00062 { 00063 } 00064 00065 unsigned int 00066 InterruptableStackThread::getTimeTillNextProcessMS() const 00067 { 00068 //.dcm. --- eventually make infinite 00069 return 10000; 00070 } 00071 00072 void 00073 InterruptableStackThread::process(FdSet& fdset) 00074 { 00075 } 00076 00077 /* ==================================================================== 00078 * The Vovida Software License, Version 1.0 00079 * 00080 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved. 00081 * 00082 * Redistribution and use in source and binary forms, with or without 00083 * modification, are permitted provided that the following conditions 00084 * are met: 00085 * 00086 * 1. Redistributions of source code must retain the above copyright 00087 * notice, this list of conditions and the following disclaimer. 00088 * 00089 * 2. Redistributions in binary form must reproduce the above copyright 00090 * notice, this list of conditions and the following disclaimer in 00091 * the documentation and/or other materials provided with the 00092 * distribution. 00093 * 00094 * 3. The names "VOCAL", "Vovida Open Communication Application Library", 00095 * and "Vovida Open Communication Application Library (VOCAL)" must 00096 * not be used to endorse or promote products derived from this 00097 * software without prior written permission. For written 00098 * permission, please contact vocal@vovida.org. 00099 * 00100 * 4. Products derived from this software may not be called "VOCAL", nor 00101 * may "VOCAL" appear in their name, without prior written 00102 * permission of Vovida Networks, Inc. 00103 * 00104 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED 00105 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00106 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND 00107 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA 00108 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES 00109 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, 00110 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00111 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00112 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00113 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00114 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00115 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 00116 * DAMAGE. 00117 * 00118 * ==================================================================== 00119 * 00120 * This software consists of voluntary contributions made by Vovida 00121 * Networks, Inc. and many individuals on behalf of Vovida Networks, 00122 * Inc. For more information on Vovida Networks, Inc., please see 00123 * <http://www.vovida.org/>. 00124 * 00125 */
1.7.5.1