From 08eda6ba48c38b9bb59e4ccec727a6cb262c5799 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?=
 <grubba@grubba.org>
Date: Mon, 30 Oct 2017 11:14:03 +0100
Subject: [PATCH] Protocols.LDAP: Use SSL in blocking mode.

SSL.File defaults to non-blocking mode and the LDAP module
attempts syncronous blocking writes. Non-blocking mode causes
these writes to eg fail with EAGAIN if the connection hasn't
finished being negotiated before the first write.

Fixes "LDAP write error: Resource temporarily unavailable".
---
 lib/modules/Protocols.pmod/LDAP.pmod/client.pike | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/modules/Protocols.pmod/LDAP.pmod/client.pike b/lib/modules/Protocols.pmod/LDAP.pmod/client.pike
index 830672ab67..34797ab1ef 100644
--- a/lib/modules/Protocols.pmod/LDAP.pmod/client.pike
+++ b/lib/modules/Protocols.pmod/LDAP.pmod/client.pike
@@ -705,6 +705,7 @@ typedef mapping(string:ResultAttributeValue) ResultEntry;
 #if constant(SSL.Cipher)
     if(lauth->scheme == "ldaps") {
       SSL.File ssl_fd = SSL.File(low_fd, context);
+      ssl_fd->set_blocking();	// NB: SSL.File defaults to non-blocking mode.
       if (!ssl_fd->connect()) {
 	ERROR("Failed to connect to LDAPS server.\n");
       }
-- 
GitLab