< Previous by Date Date Index Next by Date >
  Thread Index  

[reSIProcate] make pedantic stack runtime selectable, not compile-time



The only place that cares about the conditional flag PEDANTIC_STACK is one block of code in TransactionState.cxx. All I've done here is put a boolean flag in SipStack with an accessor, settable from the app, and look at the flag at runtime to see whether to execute the block of code. I made the SipStack constructor default this to true. Of course I also removed support for PEDANTIC_STACK from the top-level config stuff.

Because of unrelated prior local modifications to some of these files, the line numbers might not match up exactly, but they are based off 1.9.6.

I think this would be a useful change to put in the code going forward.

Thanks,

-John Gregg

Index: config.h.in
===================================================================
--- config.h.in	(revision 27529)
+++ config.h.in	(working copy)
@@ -115,9 +115,6 @@
 /* Define to the version of this package. */
 #undef PACKAGE_VERSION
 
-/* PEDANTIC_STACK */
-#undef PEDANTIC_STACK
-
 /* Host where package was configured */
 #undef REPRO_BUILD_HOST
 
Index: configure.ac
===================================================================
--- configure.ac	(revision 27529)
+++ configure.ac	(working copy)
@@ -191,10 +191,6 @@
 [  --enable-dtls           Enable DTLS support (requires OpenSSL)],
  [AC_DEFINE_UNQUOTED(USE_DTLS, 1, USE_DTLS)],  )
 
-AC_ARG_ENABLE(pedantic-stack,
-[  --enable-pedantic-stack Enable pedantic behavior (fully parse all messages)],
- [AC_DEFINE_UNQUOTED(PEDANTIC_STACK, 1, PEDANTIC_STACK)],  )
- 
 AM_CONDITIONAL(USE_MYSQL, false)
 AC_ARG_WITH(mysql,
 [  --with-mysql            Link against MySQL client libraries],
Index: configure
===================================================================
--- configure	(revision 27529)
+++ configure	(working copy)
@@ -820,7 +820,6 @@
 enable_android
 enable_ipv6
 enable_dtls
-enable_pedantic_stack
 with_mysql
 with_geoip
 with_radius
@@ -1482,7 +1481,6 @@
   --enable-android        Enable Android build
   --enable-ipv6           Enable IPv6 support
   --enable-dtls           Enable DTLS support (requires OpenSSL)
-  --enable-pedantic-stack Enable pedantic behavior (fully parse all messages)
   --enable-repro-plugins  Enable support for DSO plugins in repro
   --enable-maintainer-mode  enable make rules and dependencies not useful
 			  (and sometimes confusing) to the casual installer
@@ -15960,16 +15958,6 @@
 fi
 
 
-# Check whether --enable-pedantic-stack was given.
-if test "${enable_pedantic_stack+set}" = set; then :
-  enableval=$enable_pedantic_stack;
-cat >>confdefs.h <<_ACEOF
-#define PEDANTIC_STACK 1
-_ACEOF
-
-fi
-
-
  if false; then
   USE_MYSQL_TRUE=
   USE_MYSQL_FALSE='#'
Index: SipStack.cxx
===================================================================
--- SipStack.cxx	(revision 27856)
+++ SipStack.cxx	(working copy)
@@ -96,6 +96,7 @@
    mRunning(false),
    mShuttingDown(false),
    mStatisticsManagerEnabled(true),
+   mPedantic(true),
    mSocketFunc(socketFunc)
 {
    Timer::getTimeMs(); // initalize time offsets
@@ -1001,6 +1002,19 @@
    return mStatisticsManagerEnabled;
 }
 
+// AYLUS_CHANGE
+volatile bool&
+SipStack::pedanticStack()
+{
+    return mPedantic;
+}
+
+const bool
+SipStack::pedanticStack() const
+{
+    return mPedantic;
+}
+
 EncodeStream&
 SipStack::dump(EncodeStream& strm)  const
 {
Index: SipStack.hxx
===================================================================
--- SipStack.hxx	(revision 27856)
+++ SipStack.hxx	(working copy)
@@ -854,6 +854,10 @@
       volatile bool& statisticsManagerEnabled();
       const bool statisticsManagerEnabled() const;
 
+    // AYLUS_CHANGE - runtime pedanticStack vs. compile time PEDANTIC_STACK
+    volatile bool& pedanticStack();
+    const bool pedanticStack() const;
+
       /**
          Returns whether the stack is fixing corrupted/changed dialog 
          identifiers (ie, Call-Id and tags) in responses from the wire.
@@ -1083,6 +1087,7 @@
       bool mShuttingDown;
       mutable Mutex mShutdownMutex;
       volatile bool mStatisticsManagerEnabled;
+    volatile bool mPedantic; // AYLUS_CHANGE
 
       AfterSocketCreationFuncPtr mSocketFunc;
 
Index: TransactionState.cxx
===================================================================
--- TransactionState.cxx	(revision 27856)
+++ TransactionState.cxx	(working copy)
@@ -527,7 +527,8 @@
          }         
       }
 
-#ifdef PEDANTIC_STACK
+      if(controller.mStack.pedanticStack())  // AYLUS_CHANGE: runtime vs. compile time
+      {
       try
       {
          sip->parseAllHeaders();
@@ -541,7 +542,7 @@
          
          InfoLog(<< "Exception caught by pedantic stack: " << e);
       }
-#endif      
+      }
       
       // This ensures that CANCEL requests form unique transactions
       if (method == CANCEL)