From 2aa0a9e5f919428fa8a129a1cd0e852da0664d38 Mon Sep 17 00:00:00 2001 From: Weiqi Gao Date: Thu, 5 Mar 2015 10:31:27 -0600 Subject: [PATCH] Introduced ResourceLock to prevent a race condition between the IMR serializing the server table and the userregistering a new POA. JacORB Bugzilla Bug 1003. --- .../java/org/jacorb/imr/ImplementationRepositoryImpl.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/core/src/main/java/org/jacorb/imr/ImplementationRepositoryImpl.java b/core/src/main/java/org/jacorb/imr/ImplementationRepositoryImpl.java index 68b2eda..9d62d6c 100644 --- a/core/src/main/java/org/jacorb/imr/ImplementationRepositoryImpl.java +++ b/core/src/main/java/org/jacorb/imr/ImplementationRepositoryImpl.java @@ -117,6 +117,7 @@ public class ImplementationRepositoryImpl private WriteThread wt; private boolean updatePending; + private ResourceLock server_table_ser_lock; private Shutdown shutdownThread; @@ -128,6 +129,8 @@ public class ImplementationRepositoryImpl { this.orb = orb; + this.server_table_ser_lock = new ResourceLock(); + shutdownThread = new Shutdown (); } @@ -403,7 +406,11 @@ public class ImplementationRepositoryImpl //New POAInfo is to be created _poa = new ImRPOAInfo(name, host, port, _server, poaActivationTimeout); + + server_table_ser_lock.gainExclusiveLock(); _server.addPOA(_poa); + server_table_ser_lock.releaseExclusiveLock(); + server_table.putPOA(name, _poa); this.logger.debug("ImR: new poa registered"); @@ -1624,12 +1631,17 @@ public class ImplementationRepositoryImpl { try { + server_table_ser_lock.gainExclusiveLock(); save_server_table (table_file); } catch (FileOpFailed ex) { logger.error("Exception while saving server table", ex); } + finally + { + server_table_ser_lock.releaseExclusiveLock(); + } if (done) { -- 2.1.0