bearded / ruby-ldap

Ruby/LDAP is an extension library for Ruby. It provides the interface to some LDAP libraries (e.g. OpenLDAP, Netscape SDK and Active Directory). The common API for application development is described in RFC1823 and is supported by Ruby/LDAP.
http://rubyforge.org/projects/ruby-ldap/
Other
66 stars 34 forks source link

LDAP_OPT_NETWORK_TIMEOUT for openLDAP #22

Closed dacamp closed 11 years ago

dacamp commented 11 years ago

Thanks for actively maintaining this, it's been very handy.

I've been using it in a rails application and noticed that while connecting to a remote server, the application would get hung up for 30 seconds or so if the remote server was unreachable. Even Timeout wouldn't break the pause.

On systems using openLDAP, you can set a max network timeout LDAP_OPT_NETWORK_TIMEOUT, and I've tried to add that as best I could. If you think it'd be helpful, please review what I've got and let me know if I can answer any questions.

I have tested it with both 1.8 and 1.9, which are the two mentioned in your README. I can test 2.0.0 if you'd like.

I had to implicitly declare rb_time_interval in rbldap.h for ruby 1.8. I'm not exactly sure why, but if you have a more elegant solution, I can update my pull or you can just make the changes as needed.

Thanks!

dacamp commented 11 years ago

After testing on OS X I ran into a bug with NULL tv_sec, so I made 1dcbbb3.

I've also now tested on OS X and Ubuntu using these rubies:

 ruby-1.8.7-p374
 ruby-1.9.3-p448
 ruby-2.0.0-p247

If you'd like me to merge those two commits on conn.c and then open a new pull request, just let me know.

ghost commented 11 years ago

Hello @dacamp, thank you for this fix!

"two commits on conn.c" already included in this pull request, so no need to create new one :)

But would be good if you could do rebase of your repository and combine three commits in one.

As soon as you do rebase, I will merge this pull request.

dacamp commented 11 years ago

Cool trick with rebase, done, thanks!

I think I fixed up the formatting, I had things tabified, sorry about that.