Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Connection timeout added.

  • Loading branch information...
commit 51a3263a6907e185930680ace425a2a737ebcc0d 1 parent 0940e73
Jeremy Childs authored January 04, 2013

Showing 1 changed file with 8 additions and 0 deletions. Show diff stats Hide diff stats

  1. 8  src/LDAP.cc
8  src/LDAP.cc
@@ -226,6 +226,7 @@ class LDAPConnection : public ObjectWrap
226 226
 
227 227
     ARG_STR(uri, 0);
228 228
     ARG_INT(ver, 1);
  229
+    ARG_INT(timeout, 2);
229 230
 
230 231
     LJSDEB("OPEN1 %s:%u %p %p\n", c, c->ld);
231 232
 
@@ -241,6 +242,13 @@ class LDAPConnection : public ObjectWrap
241 242
       THROW("Error init LDAP");
242 243
     }
243 244
 
  245
+    if (timeout != -1) {
  246
+      ntimeout.tv_sec = timeout;
  247
+    }
  248
+
  249
+    struct timeval ntimeout = { timeout, 0 };
  250
+    ldap_set_option(c->ld, LDAP_OPT_NETWORK_TIMEOUT, &ntimeout);
  251
+
244 252
     ldap_set_option(c->ld, LDAP_OPT_RESTART, LDAP_OPT_ON);
245 253
     ldap_set_option(c->ld, LDAP_OPT_PROTOCOL_VERSION, &ver);
246 254
 

0 notes on commit 51a3263

Please sign in to comment.
Something went wrong with that request. Please try again.