Close the connection when done, does wonders for your number of file descriptors.
This commit is contained in:
		
							parent
							
								
									a3e8822019
								
							
						
					
					
						commit
						f89d220ac6
					
				| 
						 | 
				
			
			@ -108,10 +108,11 @@ handle_call({login, Username, Password}, _From,
 | 
			
		|||
               _ ->
 | 
			
		||||
                   Opts0
 | 
			
		||||
           end,
 | 
			
		||||
    Dn = lists:flatten(io_lib:format(UserDnPattern, [Username])),
 | 
			
		||||
    case eldap:open(Servers, Opts) of
 | 
			
		||||
        {ok, LDAP} ->
 | 
			
		||||
            Dn = lists:flatten(io_lib:format(UserDnPattern, [Username])),
 | 
			
		||||
            Reply = case eldap:simple_bind(LDAP, Dn, Password) of
 | 
			
		||||
            Reply = try
 | 
			
		||||
                        case eldap:simple_bind(LDAP, Dn, Password) of
 | 
			
		||||
                            ok ->
 | 
			
		||||
                                {ok, #user{username     = Username,
 | 
			
		||||
                                           is_admin     = false,
 | 
			
		||||
| 
						 | 
				
			
			@ -121,6 +122,9 @@ handle_call({login, Username, Password}, _From,
 | 
			
		|||
                                {refused, Username};
 | 
			
		||||
                            {error, _} = E ->
 | 
			
		||||
                                E
 | 
			
		||||
                        end
 | 
			
		||||
                    after
 | 
			
		||||
                        eldap:close(LDAP)
 | 
			
		||||
                    end,
 | 
			
		||||
            {reply, Reply, State};
 | 
			
		||||
        Error ->
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue