Commit 3a7fb0d1 authored by Renato Figueiro Maia's avatar Renato Figueiro Maia
Browse files

[OPENBUS-1284] Barramento pára de responder caso o LDAP tenha problemas

- Correção na criação da thread para execução do servidor CORBA que exporta as funcionalidades da biblioteca de acesso do OpenLDAP.
- Incorporando a sugestão do Amadeu de não utilizar um arquivo fixo para armazenar o IOR (propriedade 'ldap_iorpath' ou um 'os.tmpname').

git-svn-id: https://subversion.tecgraf.puc-rio.br/engdist/openbus/core/branches/02_00_00@163622 ae0415b3-e90b-0410-900d-d0be9363c56b
parent e4267f47
......@@ -19,6 +19,9 @@ local type = _G.type
local array = require "table"
local concat = array.concat
local os = require "os"
local tmpname = os.tmpname
local thread = require "openbus.util.thread"
local spawn = thread.spawn
......@@ -39,6 +42,7 @@ return function(configs)
return nil, msg.LdapBadTimeout:tag{value=timeout,type=type(timeout)}
end
local cleartext = configs.ldap_cleartext
local iorpath = configs.ldap_iorpath or tmpname()
-- collect server urls
local urls = {}
for _, url in ipairs(servers) do
......@@ -68,7 +72,7 @@ return function(configs)
flavor = "cooperative.server;corba.server",
host = "127.0.0.1",
}
oil.writeto("ldap.ior", orb:newservant{
oil.writeto("]=]..iorpath..[=[", orb:newservant{
__type = orb:loadidl[[]=]..idl..[=[]],
validate = function(_, url, dn, password, usetls, timeout)
if timeout == -1 then timeout = nil end
......@@ -92,13 +96,13 @@ return function(configs)
orb:loadidl(idl)
local service
repeat
local ior = oil.readfrom("ldap.ior")
local ior = oil.readfrom(iorpath)
if ior ~= nil then
local ok, res = pcall(orb.newproxy, orb, ior, nil, "LDAP")
if ok then service = res end
end
until service ~= nil
os.remove("ldap.ior")
os.remove(iorpath)
function openldap(url, dn, password, usetls, timeout)
return service:validate(url, dn, password, usetls, timeout or -1)
end
......
#include <signal.h>
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
#include <string.h>
#include <lua.h>
#include <lauxlib.h>
......@@ -224,9 +224,9 @@ static int l_spawn (lua_State *L)
lua_State *newL = luaL_newstate(); /* create state */
if (newL == NULL) luaL_error(L, "not enough memory");
lua_getfield(L, LUA_REGISTRYINDEX, "OPENBUS_DEBUG");
copypreload(L, newL);
status = openbuslua_init(newL, 0, !lua_isnil(L, -1));
if (status == LUA_OK) {
copypreload(L, newL);
status = luaL_loadbuffer(newL, code, codelen, code);
if (status == LUA_OK) {
int res = newthread(luathread, newL);
......
Supports Markdown
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