Commit 4255558a authored by Renato Figueiro Maia's avatar Renato Figueiro Maia

Revertendo commit errado: r157998

Comando utilizado: 'svn merge -c -157998 .'


git-svn-id: https://subversion.tecgraf.puc-rio.br/engdist/openbus/sdk/lua/branches/02_00_00@157999 ae0415b3-e90b-0410-900d-d0be9363c56b
parent 1dc2ad0f
......@@ -56,7 +56,7 @@ local NoPermisisonCases = {
{raised=except.minor.InvalidRemote,expected=except.minor.InvalidRemote},
{raised=except.minor.UnavailableBus,expected=except.minor.InvalidRemote},
{raised=except.minor.InvalidTarget,expected=except.minor.InvalidRemote},
{raised=except.minor.InvalidLogin,expected=except.minor.InvalidRemote},
{raised=except.minor.InvalidLogin,expected=except.minor.NoLogin},
}
-- find the offered service
......
......@@ -71,12 +71,10 @@ local CredentialContextId = coreconst.credential.CredentialContextId
local loginconst = coreconst.services.access_control
local InvalidPublicKeyCode = loginconst.InvalidPublicKeyCode
local NoLoginCode = loginconst.NoLoginCode
local InvalidRemoteCode = loginconst.InvalidRemoteCode
local InvalidLoginCode = loginconst.InvalidLoginCode
local NoCredentialCode = loginconst.NoCredentialCode
local UnknownBusCode = loginconst.UnknownBusCode
local UnverifiedLoginCode = loginconst.UnverifiedLoginCode
local UnavailableBusCode = loginconst.UnavailableBusCode
local coresrvtypes = coreidl.types.services
local logintypes = coresrvtypes.access_control
local AccessControlRepId = logintypes.AccessControl
......@@ -164,6 +162,14 @@ local function getLoginEntry(self, loginId)
end
end
local function getLoginValidity(self, loginId)
local entry = getLoginEntry(self, loginId)
if entry ~= nil then
return max(.01, entry.deadline - time())
end
return 0
end
local function getLoginInfo(self, loginId)
local entry = getLoginEntry(self, loginId)
if entry ~= nil then
......@@ -177,6 +183,7 @@ local function newLoginRegistryWrapper(LoginRegistry)
__object = LoginRegistry,
cache = LRUCache(),
getLoginEntry = getLoginEntry,
getLoginValidity = getLoginValidity,
getLoginInfo = getLoginInfo,
}
return self
......@@ -413,44 +420,31 @@ function Connection:sendrequest(request)
end
end
local InvalidLoginThreads = {}
function Connection:receivereply(request)
receiveBusReply(self, request)
local thread = running()
if request.success == false and InvalidLoginThreads[thread] == nil then
if request.success == false then
local except = request.results[1]
if is_NO_PERMISSION(except, InvalidLoginCode) then
local invlogin = request.login
if self.login == invlogin then
localLogout(self)
self.invalidLogin = invlogin
end
log:exception(msg.GotInvalidLoginException:tag{
operation = request.operation_name,
login = invlogin.id,
entity = invlogin.entity,
})
local logins = self.LoginRegistry
InvalidLoginThreads[thread] = true
local ok, result = pcall(logins.getLoginValidity, logins, invlogin.id)
InvalidLoginThreads[thread] = nil
if ok and result > 0 then
log:exception(msg.GotFalseInvalidLogin:tag{
invlogin = invlogin.id,
})
except.minor = InvalidRemoteCode
elseif ok or is_NO_PERMISSION(result, InvalidLoginCode) then
if self.login == invlogin then
localLogout(self)
self.invalidLogin = invlogin
end
local login = getLogin(self)
if login ~= nil then
request.success = nil -- reissue request to the same reference
log:action(msg.ReissueCallAfterInvalidLogin:tag{
operation = request.operation_name,
login = login.id,
entity = login.entity,
})
else
log:exception(msg.UnableToVerifyOwnLoginValidity:tag{
error = result,
invlogin = invlogin.id,
})
except.minor = UnavailableBusCode
except.minor = NoLoginCode
end
end
end
......@@ -466,18 +460,20 @@ function Connection:receiverequest(request)
})
setNoPermSysEx(request, NoCredentialCode)
end
elseif is_NO_PERMISSION(ex, NoLoginCode) then
log:exception(msg.LostLoginDuringCallDispatch:tag{
operation = request.operation.name,
})
setNoPermSysEx(request, UnknownBusCode)
elseif is_TRANSIENT(ex) or is_COMM_FAILURE(ex) then
log:exception(msg.UnableToVerifyLoginDueToCoreServicesUnaccessible:tag{
operation = request.operation.name,
})
setNoPermSysEx(request, UnverifiedLoginCode)
else
error(ex)
if is_NO_PERMISSION(ex, NoLoginCode) then
log:exception(msg.LostLoginDuringCallDispatch:tag{
operation = request.operation.name,
})
setNoPermSysEx(request, UnknownBusCode)
elseif is_TRANSIENT(ex) or is_COMM_FAILURE(ex) then
log:exception(msg.UnableToVerifyLoginDueToCoreServicesUnaccessible:tag{
operation = request.operation.name,
})
setNoPermSysEx(request, UnverifiedLoginCode)
else
error(ex)
end
end
else
log:exception(msg.GotCallWhileNotLoggedIn:tag{
......
......@@ -347,13 +347,6 @@ for _, connOp in ipairs({"DefaultConnection", "CurrentConnection"}) do
assert(called); called = nil
assertlogoff(conn)
relogin()
-- during logout
assert(called == nil)
invalidate(conn.login.id)
assert(conn:logout() == false)
assert(called == nil)
assertlogoff(conn)
relogin()
end
do log:TEST "reconnect"
......@@ -375,13 +368,6 @@ for _, connOp in ipairs({"DefaultConnection", "CurrentConnection"}) do
invalidate(conn.login.id)
callwithin(conn, OfferRegistry.findServices, OfferRegistry, {})
assert(called); called = nil
-- during logout
assert(called == nil)
invalidate(conn.login.id)
assert(conn:logout() == false)
assert(called == nil)
assertlogoff(conn)
relogin()
end
do log:TEST "raise error"
......@@ -405,14 +391,6 @@ for _, connOp in ipairs({"DefaultConnection", "CurrentConnection"}) do
assert(ex.completed == "COMPLETED_NO")
assert(ex.minor == idl.const.services.access_control.NoLoginCode)
assert(called); called = nil
assertlogoff(conn)
relogin()
-- during logout
assert(called == nil)
invalidate(conn.login.id)
assert(conn:logout() == false)
assert(called == nil)
assertlogoff(conn)
end
log:TEST(false)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment