Skip to content

Fix set_option() of timeout to handle -1 as infinity #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 4, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Allow set_option() to set timeout to infinity
OPT_TIMEOUT and OPT_NETWORK_TIMEOUT now support -1 to set default back
to infinity.

Signed-off-by: Christian Heimes <cheimes@redhat.com>
  • Loading branch information
tiran authored and encukou committed Dec 4, 2017
commit dcb5c0052b5f83508c1c406d8ad0b23e4f5a3e6a
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Modules/
* Fix memory leak in whoami
* Fix internal error handling of LDAPControl_to_List()
* Fix two memory leaks and release GIL in encode_assertion_control
* Allow set_option() to set timeouts to infinity
and, thanks to Michael Ströder:
* removed unused code schema.c
* moved code from version.c to ldapmodule.c
Expand Down
6 changes: 6 additions & 0 deletions Doc/reference/ldap.rst
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ following option identifiers are defined as constants:

.. py:data:: OPT_NETWORK_TIMEOUT

.. versionchanged:: 3.0
A timeout of ``-1`` resets timeout to infinity.

.. py:data:: OPT_PROTOCOL_VERSION

Sets the LDAP protocol version used for a connection. This is mapped to
Expand All @@ -180,6 +183,9 @@ following option identifiers are defined as constants:

.. py:data:: OPT_TIMEOUT

.. versionchanged:: 3.0
A timeout of ``-1`` resets timeout to infinity.

.. py:data:: OPT_URI

.. _ldap-sasl-options:
Expand Down
14 changes: 12 additions & 2 deletions Modules/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,20 @@ LDAP_set_option(LDAPObject *self, int option, PyObject *value)
if (!PyArg_Parse(value, "d:set_option", &doubleval))
return 0;
if (doubleval >= 0) {
set_timeval_from_double( &tv, doubleval );
set_timeval_from_double( &tv, doubleval );
ptr = &tv;
} else if (doubleval == -1) {
/* -1 is infinity timeout */
tv.tv_sec = -1;
tv.tv_usec = 0;
ptr = &tv;
} else {
ptr = NULL;
PyErr_Format(
PyExc_ValueError,
"timeout must be >= 0 or -1 for infinity, got %d",
option
);
return 0;
}
break;
case LDAP_OPT_SERVER_CONTROLS:
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy