Permalink
Browse files

Connection timeout added.

  • Loading branch information...
1 parent 0940e73 commit 51a3263a6907e185930680ace425a2a737ebcc0d @jeremycx committed Jan 4, 2013
Showing with 8 additions and 0 deletions.
  1. +8 −0 src/LDAP.cc
View
8 src/LDAP.cc
@@ -226,6 +226,7 @@ class LDAPConnection : public ObjectWrap
ARG_STR(uri, 0);
ARG_INT(ver, 1);
+ ARG_INT(timeout, 2);
LJSDEB("OPEN1 %s:%u %p %p\n", c, c->ld);
@@ -241,6 +242,13 @@ class LDAPConnection : public ObjectWrap
THROW("Error init LDAP");
}
+ if (timeout != -1) {
+ ntimeout.tv_sec = timeout;
+ }
+
+ struct timeval ntimeout = { timeout, 0 };
+ ldap_set_option(c->ld, LDAP_OPT_NETWORK_TIMEOUT, &ntimeout);
+
ldap_set_option(c->ld, LDAP_OPT_RESTART, LDAP_OPT_ON);
ldap_set_option(c->ld, LDAP_OPT_PROTOCOL_VERSION, &ver);

0 comments on commit 51a3263

Please sign in to comment.