From 3fcdfd72cef3bdc84a5d6ede67f46f07acd6d76a Mon Sep 17 00:00:00 2001 From: hns Date: Thu, 6 Dec 2007 20:18:59 +0000 Subject: [PATCH] * Invoke User.onLogout() if and only if a request evaluator is associated with the current thread (which means it is called from an application script). Otherwise, we can assume to be called by the session timeout thread, which takes care of calling User.onLogout(). --- src/helma/framework/core/Session.java | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/helma/framework/core/Session.java b/src/helma/framework/core/Session.java index 162bb4dc..d6da2023 100644 --- a/src/helma/framework/core/Session.java +++ b/src/helma/framework/core/Session.java @@ -101,23 +101,25 @@ public class Session implements Serializable { */ public void logout() { if (userHandle != null) { - // invoke User.onLogout - RequestEvaluator reval = null; try { - reval = app.getEvaluator(); - reval.invokeInternal(userHandle, "onLogout", new Object[] {sessionId}); + // Invoke User.onLogout() iff this is a transactor request with a request + // evaluator already associated (i.e., if this is called from an app/script). + // Otherwise, we assume being called from the scheduler thread, which takes + // care of calling User.onLogout(). + RequestEvaluator reval = app.getCurrentRequestEvaluator(); + if (reval != null) { + Node userNode = userHandle.getNode(app.nmgr.safe); + if (userNode != null) + reval.invokeDirectFunction(userNode, "onLogout", new Object[] {sessionId}); + } } catch (Exception x) { - // errors should already be logged by requestevaluator, but you never know + // errors should already be logged by request evaluator, but you never know app.logError("Error in onLogout", x); } finally { - // do the actual work + // do log out userHandle = null; uid = null; lastModified = System.currentTimeMillis(); - // release the evaluator - if (reval != null) { - app.releaseEvaluator(reval); - } } } }