2 new revisions:

Revision: 0961590c896a
Author:   [email protected] <[email protected]>
Date:     Tue Jun 25 06:42:45 2013
Log: Fixed Issue #297 TCAP : Race condition when setting 'dialogIdleTimeout...
http://code.google.com/p/jss7/source/detail?r=0961590c896a

Revision: a3842b771a58
Author:   [email protected] <[email protected]>
Date:     Tue Jun 25 06:54:04 2013
Log:      Merge branch 'master' of https://code.google.com/p/jss7
http://code.google.com/p/jss7/source/detail?r=a3842b771a58

==============================================================================
Revision: 0961590c896a
Author:   [email protected] <[email protected]>
Date:     Tue Jun 25 06:42:45 2013
Log: Fixed Issue #297 TCAP : Race condition when setting 'dialogIdleTimeout' and 'invokeTimeout' in TCAPStack

http://code.google.com/p/jss7/source/detail?r=0961590c896a

Modified:
/tcap/tcap-api/src/main/java/org/mobicents/protocols/ss7/tcap/api/TCAPStack.java /tcap/tcap-impl/src/main/java/org/mobicents/protocols/ss7/tcap/TCAPProviderImpl.java /tcap/tcap-impl/src/main/java/org/mobicents/protocols/ss7/tcap/TCAPStackImpl.java

=======================================
--- /tcap/tcap-api/src/main/java/org/mobicents/protocols/ss7/tcap/api/TCAPStack.java Mon May 20 13:09:00 2013 +++ /tcap/tcap-api/src/main/java/org/mobicents/protocols/ss7/tcap/api/TCAPStack.java Tue Jun 25 06:42:45 2013
@@ -46,7 +46,10 @@
* @throws IllegalStateException - if stack is already running or not configured
      * @throws StartFailedException
      */
-    void start() throws IllegalStateException;
+    void start() throws Exception;
+
+
+    public boolean isStarted();

     /**
* Sets millisecond value for dialog timeout. It specifies how long dialog can be idle - not receive/send any messages.
=======================================
--- /tcap/tcap-impl/src/main/java/org/mobicents/protocols/ss7/tcap/TCAPProviderImpl.java Tue Jun 18 12:56:52 2013 +++ /tcap/tcap-impl/src/main/java/org/mobicents/protocols/ss7/tcap/TCAPProviderImpl.java Tue Jun 25 06:42:45 2013
@@ -442,17 +442,6 @@
     void start() {
         logger.info("Starting TCAP Provider");

-        if (stack.getDialogIdRangeStart() >= stack.getDialogIdRangeEnd())
- throw new IllegalArgumentException("Range start value cannot be equal/greater than Range end value");
-        if (stack.getDialogIdRangeStart() < 1)
- throw new IllegalArgumentException("Range start value must be greater or equal 1");
-        if (stack.getDialogIdRangeEnd() > Integer.MAX_VALUE)
- throw new IllegalArgumentException("Range end value must be less or equal " + Integer.MAX_VALUE); - if (stack.getDialogIdRangeEnd() - stack.getDialogIdRangeStart() < 10000) - throw new IllegalArgumentException("Range \"end - start\" must has at least 10000 possible dialogs"); - if (stack.getDialogIdRangeEnd() - stack.getDialogIdRangeStart() <= stack.maxDialogs) - throw new IllegalArgumentException("MaxDialog must be less than DialogIdRange");
-
         this._EXECUTOR = Executors.newScheduledThreadPool(4);
         this.sccpProvider.registerSccpListener(ssn, this);
         logger.info("Registered SCCP listener with address " + ssn);
=======================================
--- /tcap/tcap-impl/src/main/java/org/mobicents/protocols/ss7/tcap/TCAPStackImpl.java Mon May 20 13:09:00 2013 +++ /tcap/tcap-impl/src/main/java/org/mobicents/protocols/ss7/tcap/TCAPStackImpl.java Tue Jun 25 06:42:45 2013
@@ -31,7 +31,7 @@
 /**
  * @author amit bhayani
  * @author baranowb
- *
+ *
  */
 public class TCAPStackImpl implements TCAPStack {

@@ -47,7 +47,7 @@
     private SccpProvider sccpProvider;
     private SccpAddress address;

-    private State state = State.IDLE;
+    private volatile boolean started = false;

     private long dialogTimeout = _DIALOG_TIMEOUT;
     private long invokeTimeout = _INVOKE_TIMEOUT;
@@ -67,37 +67,54 @@
     public TCAPStackImpl(SccpProvider sccpProvider, int ssn) {
         this.sccpProvider = sccpProvider;
         this.tcapProvider = new TCAPProviderImpl(sccpProvider, this, ssn);
-        this.state = State.CONFIGURED;
     }

-    public void start() throws IllegalStateException {
+    public void start() throws Exception {
         logger.info("Starting ..." + tcapProvider);
+
+        if (this.getDialogIdRangeStart() >= this.getDialogIdRangeEnd())
+ throw new IllegalArgumentException("Range start value cannot be equal/greater than Range end value");
+        if (this.getDialogIdRangeStart() < 1)
+ throw new IllegalArgumentException("Range start value must be greater or equal 1");
+        if (this.getDialogIdRangeEnd() > Integer.MAX_VALUE)
+ throw new IllegalArgumentException("Range end value must be less or equal " + Integer.MAX_VALUE); + if ((this.getDialogIdRangeEnd() - this.getDialogIdRangeStart()) < 10000) + throw new IllegalArgumentException("Range \"end - start\" must has at least 10000 possible dialogs"); + if ((this.getDialogIdRangeEnd() - this.getDialogIdRangeStart()) <= this.maxDialogs) + throw new IllegalArgumentException("MaxDialog must be less than DialogIdRange");
+
+        if (this.dialogTimeout < 0) {
+ throw new IllegalArgumentException("DialogIdleTimeout value must be greater or equal to zero.");
+        }
+
+        if (this.dialogTimeout < this.invokeTimeout) {
+ throw new IllegalArgumentException("DialogIdleTimeout value must be greater or equal to invoke timeout.");
+        }
+
+        if (this.invokeTimeout < 0) {
+ throw new IllegalArgumentException("InvokeTimeout value must be greater or equal to zero.");
+        }
+
         tcapProvider.start();
+
+        this.started = true;
     }

     public void stop() {
         this.tcapProvider.stop();
-        this.state = State.CONFIGURED;
+        this.started = false;
     }

-    // // ///////////////
-    // // CONF METHOD //
-    // // ///////////////
-    // /**
-    // *
-    // */
- // public void configure(Properties props) throws ConfigurationException {
-    // if (state != State.IDLE) {
- // throw new IllegalStateException("Stack already been configured or is already running!");
-    // }
-    // //this.sccpProvider = this.sccpStack.getSccpProvider();
- // this.tcapProvider = new TCAPProviderImpl(sccpProvider, this, address);
-    // this.state = State.CONFIGURED;
-    // }
+    /**
+     * @return the started
+     */
+    public boolean isStarted() {
+        return this.started;
+    }

     /*
      * (non-Javadoc)
-     *
+     *
      * @see org.mobicents.protocols.ss7.tcap.api.TCAPStack#getProvider()
      */
     public TCAPProvider getProvider() {
@@ -107,15 +124,18 @@

     /*
      * (non-Javadoc)
-     *
+     *
* @see org.mobicents.protocols.ss7.tcap.api.TCAPStack#setDialogIdleTimeout(long)
      */
     public void setDialogIdleTimeout(long v) {
-        if (v < 0) {
- throw new IllegalArgumentException("Timeout value must be greater or equal to zero.");
-        }
-        if (v < this.invokeTimeout) {
- throw new IllegalArgumentException("Timeout value must be greater or equal to invoke timeout.");
+
+        if (this.isStarted()) {
+            if (v < 0) {
+ throw new IllegalArgumentException("DialogIdleTimeout value must be greater or equal to zero.");
+            }
+            if (v < this.invokeTimeout) {
+ throw new IllegalArgumentException("DialogIdleTimeout value must be greater or equal to invoke timeout.");
+            }
         }

         this.dialogTimeout = v;
@@ -123,7 +143,7 @@

     /*
      * (non-Javadoc)
-     *
+     *
* @see org.mobicents.protocols.ss7.tcap.api.TCAPStack#getDialogIdleTimeout()
      */
     public long getDialogIdleTimeout() {
@@ -132,32 +152,29 @@

     /*
      * (non-Javadoc)
-     *
+     *
* @see org.mobicents.protocols.ss7.tcap.api.TCAPStack#setInvokeTimeout(long)
      */
     public void setInvokeTimeout(long v) {
-        if (v < 0) {
- throw new IllegalArgumentException("Timeout value must be greater or equal to zero.");
-        }
-        if (v > this.dialogTimeout) {
- throw new IllegalArgumentException("Timeout value must be smaller or equal to dialog timeout.");
+        if (this.isStarted()) {
+            if (v < 0) {
+ throw new IllegalArgumentException("InvokeTimeout value must be greater or equal to zero.");
+            }
+            if (v > this.dialogTimeout) {
+ throw new IllegalArgumentException("InvokeTimeout value must be smaller or equal to dialog timeout.");
+            }
         }
         this.invokeTimeout = v;
     }

     /*
      * (non-Javadoc)
-     *
+     *
* @see org.mobicents.protocols.ss7.tcap.api.TCAPStack#getInvokeTimeout()
      */
     public long getInvokeTimeout() {
         return this.invokeTimeout;
     }
-
-    private enum State {
-
-        IDLE, CONFIGURED, RUNNING;
-    }

     public void setMaxDialogs(int v) {
         if (v < 1)

==============================================================================
Revision: a3842b771a58
Author:   [email protected] <[email protected]>
Date:     Tue Jun 25 06:54:04 2013
Log:      Merge branch 'master' of https://code.google.com/p/jss7

http://code.google.com/p/jss7/source/detail?r=a3842b771a58


--

--- You received this message because you are subscribed to the Google Groups "mobicents-commits" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to