Author: bpapez
Date: Wed Jan 2 17:37:47 2008
New Revision: 19440
URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D19440&repname=
=3Djahia
Log:
JAHIA-2686: Problem with Latch not being released
- Moved the avoidParallelProcessingOfSamePage into the try-catch bracket to=
always release a latch, when it has been acquired by this thread
Modified:
branches/JAHIA-4-1-BRANCH/src/java/org/jahia/operations/OperationManage=
r.java
Modified: branches/JAHIA-4-1-BRANCH/src/java/org/jahia/operations/Operation=
Manager.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-4-1-BR=
ANCH/src/java/org/jahia/operations/OperationManager.java&rev=3D19440&repnam=
e=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-4-1-BRANCH/src/java/org/jahia/operations/OperationManage=
r.java (original)
+++ branches/JAHIA-4-1-BRANCH/src/java/org/jahia/operations/OperationManage=
r.java Wed Jan 2 17:37:47 2008
@@ -145,39 +145,19 @@
// check if the page is already generating or is generated
// force generation
Latch latch =3D null;
-
- // boolean which indicate if we have to generate the page or we
- // must
- // wait for the cache to be generated
- boolean mustBeWaited =3D false;
-
- if (pageState !=3D null && pageState.isCacheable
- && !notCacheablePage.containsKey(pageState.getKey())) {
- synchronized (generatingPage) {
- if (!generatingPage.containsKey(pageState.getKey())) {
- latch =3D new Latch();
- generatingPage.put(pageState.getKey(), latch);
- } else {
- latch =3D (Latch) generatingPage.get(pageState
- .getKey());
- mustBeWaited =3D true;
- }
- }
- try {
- if (mustBeWaited) {
- if (!latch.attempt(jParams.settings().getPageGener=
ationWaitTime())) {
- throw new JahiaServerOverloadedException();
- }
- if (checkCache(jParams, null))
- return;
- }
- } catch (InterruptedException ie) {
- logger.debug("The waiting thread has been interrupted =
:",
- ie);
- }
- }
boolean semaphoreAcquired =3D false;
+ =
try {
+ // boolean which indicate if we have to generate the page =
or we
+ // must wait for the cache to be generated
+ if (pageState !=3D null && pageState.isCacheable
+ && !notCacheablePage.containsKey(pageState.getKey(=
))) {
+ latch =3D avoidParallelProcessingOfSamePage(pageState,
+ jParams);
+ if (checkCache(jParams, null))
+ return;
+ }
+ =
if (!availableProcessings.attempt(jParams.settings().getPa=
geGenerationWaitTime())){
throw new JahiaServerOverloadedException();
} else {
@@ -186,23 +166,63 @@
processPage(jParams, theEngine);
} catch (InterruptedException ie) {
logger.debug("The waiting thread has been interrupted :",
- ie); =
+ ie);
+ throw new JahiaException("Request processing was interrupt=
ed",
+ "Request processing was interrupted", JahiaExcepti=
on.SERVICE_ERROR,
+ JahiaException.ERROR_SEVERITY, ie); =
} finally {
if (semaphoreAcquired) {
availableProcessings.release();
}
if (latch !=3D null) {
latch.release();
- }
- if (pageState !=3D null && pageState.getKey() !=3D null) {
- synchronized (generatingPage) {
- generatingPage.remove(pageState.getKey());
- }
+ =
+ if (pageState !=3D null && pageState.getKey() !=3D nul=
l) {
+ synchronized (generatingPage) {
+ generatingPage.remove(pageState.getKey());
+ }
+ } =
}
}
}
}
=
+ private Latch avoidParallelProcessingOfSamePage(PageState state,
+ ParamBean jParams) throws JahiaException {
+ Latch latch =3D null;
+ boolean mustWait =3D false;
+ Object entryKey =3D state.getKey();
+ synchronized (generatingPage) {
+ if (!generatingPage.containsKey(entryKey)) {
+ latch =3D new Latch();
+ generatingPage.put(entryKey, latch);
+ } else {
+ latch =3D (Latch) generatingPage.get(entryKey);
+ mustWait =3D true;
+ }
+ }
+ if (mustWait) {
+ try {
+ if (!latch.attempt(jParams.settings()
+ .getPageGenerationWaitTime())) {
+ throw new JahiaServerOverloadedException();
+ }
+ latch =3D null;
+ } catch (InterruptedException ie) {
+ logger.debug("The waiting thread has been interrupted :", =
ie);
+ throw new JahiaException("Request processing was interrupt=
ed",
+ "Request processing was interrupted", JahiaExcepti=
on.SERVICE_ERROR,
+ JahiaException.ERROR_SEVERITY, ie);
+ } catch (Throwable je) {
+ throw new JahiaException("Error when queueing requests",
+ "Error when queueing requests", JahiaException.SER=
VICE_ERROR,
+ JahiaException.ERROR_SEVERITY, je);
+ }
+ }
+ =
+ return latch;
+ } =
+ =
private void processPage(ParamBean jParams, JahiaEngine theEngine)
throws JahiaException {
try {
_______________________________________________
cvs_list mailing list
[email protected]
http://lists.jahia.org/cgi-bin/mailman/listinfo/cvs_list