From: Julio G. <ju...@us...> - 2004-08-24 12:43:31
|
Update of /cvsroot/smartfrog/core/smartfrog/src/org/smartfrog/sfcore/prim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19801/smartfrog/src/org/smartfrog/sfcore/prim Modified Files: PrimImpl.java Log Message: SF-29 Fix for race condition between sfIsTerminated and sfPing(). Index: PrimImpl.java =================================================================== RCS file: /cvsroot/smartfrog/core/smartfrog/src/org/smartfrog/sfcore/prim/PrimImpl.java,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** PrimImpl.java 13 Aug 2004 15:37:14 -0000 1.37 --- PrimImpl.java 24 Aug 2004 12:43:05 -0000 1.38 *************** *** 106,109 **** --- 106,113 ---- /** Flag indicating that this component has been terminated. */ protected boolean sfIsTerminated = false; + /** Flag indicating that this component termination is initiated. */ + protected boolean sfIsTerminating = false; + + boolean isTerminating = true; /** Flag indicating that this component has been deployed. */ *************** *** 774,777 **** --- 778,782 ---- // Provide ID to termination record // Note that it uses the name of the first component terminated not the actual caller id. + if (status.id == null) { try { *************** *** 790,798 **** synchronized (this) { ! if (sfIsTerminated) { return; } ! sfStopLivenessSender(); ! sfIsTerminated = true; } --- 795,802 ---- synchronized (this) { ! if (sfIsTerminating) { return; } ! isTerminating = true; } *************** *** 821,824 **** --- 825,835 ---- } + synchronized (this) { + if (sfIsTerminated) { + return; + } + sfIsTerminated = true; + } + } *************** *** 921,932 **** */ public void sfPing(Object source) throws SmartFrogLivenessException, RemoteException { - if (sfIsTerminated) { - throw new SmartFrogLivenessException("Component Terminated"); - } if ((source == null) || (sfParent == null)) { return; } if (source.equals(sfParent)) { sfLivenessCount = sfLivenessFactor; --- 932,947 ---- */ public void sfPing(Object source) throws SmartFrogLivenessException, RemoteException { if ((source == null) || (sfParent == null)) { + if (sfIsTerminated) { + throw new SmartFrogLivenessException("Component Terminated"); + } return; } + if (sfIsTerminated && !source.equals(sfParent)) { + throw new SmartFrogLivenessException("Component Terminated"); + } + if (source.equals(sfParent)) { sfLivenessCount = sfLivenessFactor; |