mirror of
https://github.com/moodle/moodle.git
synced 2025-01-31 20:53:53 +01:00
eee34307b9
Both CAS and LDAP auth plugins open new connections to the LDAP server to get the user account details. While this is the desired behaviour for regular logins (we probably don't have an already open connection to the LDAP server), this is a ressource hog when we are doing user synchronization, as the closed connections remain in the TCP_WAIT state for a while before the server can reuse them. If we are syncing a lot of users, we can make the server run out of available TCP ressources. So we cache the connection the first time we establish it and return the same connection handle everytime, unless we've closed all the 'open' connections, or the auth object is destroyed. In addition to that, there were a few missing calls to ldap_close().