Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Joe Martin
OpenLDAP
Commits
0c542682
Commit
0c542682
authored
Feb 05, 2007
by
Howard Chu
Browse files
Timeouts should not be malloc'd
parent
4e193bc5
Changes
9
Hide whitespace changes
Inline
Side-by-side
libraries/libldap/init.c
View file @
0c542682
...
...
@@ -259,7 +259,6 @@ static void openldap_ldap_init_w_conf(
case
ATTR_OPT_TV
:
{
struct
timeval
tv
;
char
*
next
;
tv
.
tv_sec
=
-
1
;
tv
.
tv_usec
=
0
;
tv
.
tv_sec
=
strtol
(
opt
,
&
next
,
10
);
if
(
next
!=
opt
&&
next
[
0
]
==
'\0'
&&
tv
.
tv_sec
>
0
)
{
...
...
@@ -476,8 +475,8 @@ void ldap_int_initialize_global_options( struct ldapoptions *gopts, int *dbglvl
gopts
->
ldo_timelimit
=
LDAP_NO_LIMIT
;
gopts
->
ldo_sizelimit
=
LDAP_NO_LIMIT
;
gopts
->
ldo_tm_api
=
(
struct
timeval
*
)
NULL
;
gopts
->
ldo_tm_net
=
(
struct
timeval
*
)
NULL
;
gopts
->
ldo_tm_api
.
tv_sec
=
-
1
;
gopts
->
ldo_tm_net
.
tv_sec
=
-
1
;
/* ldo_defludp will be freed by the termination handler
*/
...
...
libraries/libldap/ldap-int.h
View file @
0c542682
...
...
@@ -173,8 +173,8 @@ struct ldapoptions {
#endif
/* per API call timeout */
struct
timeval
*
ldo_tm_api
;
struct
timeval
*
ldo_tm_net
;
struct
timeval
ldo_tm_api
;
struct
timeval
ldo_tm_net
;
ber_int_t
ldo_version
;
ber_int_t
ldo_deref
;
...
...
libraries/libldap/open.c
View file @
0c542682
...
...
@@ -122,8 +122,6 @@ ldap_create( LDAP **ldp )
/* but not pointers to malloc'ed items */
ld
->
ld_options
.
ldo_sctrls
=
NULL
;
ld
->
ld_options
.
ldo_cctrls
=
NULL
;
ld
->
ld_options
.
ldo_tm_api
=
NULL
;
ld
->
ld_options
.
ldo_tm_net
=
NULL
;
ld
->
ld_options
.
ldo_defludp
=
NULL
;
#ifdef HAVE_CYRUS_SASL
...
...
@@ -146,14 +144,6 @@ ldap_create( LDAP **ldp )
ld
->
ld_options
.
ldo_tls_ctx
=
NULL
;
#endif
if
(
gopts
->
ldo_tm_api
&&
ldap_int_timeval_dup
(
&
ld
->
ld_options
.
ldo_tm_api
,
gopts
->
ldo_tm_api
))
goto
nomem
;
if
(
gopts
->
ldo_tm_net
&&
ldap_int_timeval_dup
(
&
ld
->
ld_options
.
ldo_tm_net
,
gopts
->
ldo_tm_net
))
goto
nomem
;
if
(
gopts
->
ldo_defludp
)
{
ld
->
ld_options
.
ldo_defludp
=
ldap_url_duplist
(
gopts
->
ldo_defludp
);
...
...
@@ -178,8 +168,6 @@ ldap_create( LDAP **ldp )
nomem:
ldap_free_select_info
(
ld
->
ld_selectinfo
);
ldap_free_urllist
(
ld
->
ld_options
.
ldo_defludp
);
LDAP_FREE
(
ld
->
ld_options
.
ldo_tm_net
);
LDAP_FREE
(
ld
->
ld_options
.
ldo_tm_api
);
#ifdef HAVE_CYRUS_SASL
LDAP_FREE
(
ld
->
ld_options
.
ldo_def_sasl_authzid
);
LDAP_FREE
(
ld
->
ld_options
.
ldo_def_sasl_authcid
);
...
...
libraries/libldap/options.c
View file @
0c542682
...
...
@@ -176,17 +176,11 @@ ldap_get_option(
return
LDAP_OPT_SUCCESS
;
case
LDAP_OPT_TIMEOUT
:
/* the caller has to free outvalue ! */
if
(
ldap_int_timeval_dup
(
outvalue
,
lo
->
ldo_tm_api
)
!=
0
)
{
return
LDAP_OPT_ERROR
;
}
*
(
struct
timeval
*
)
outvalue
=
lo
->
ldo_tm_api
;
return
LDAP_OPT_SUCCESS
;
case
LDAP_OPT_NETWORK_TIMEOUT
:
/* the caller has to free outvalue ! */
if
(
ldap_int_timeval_dup
(
outvalue
,
lo
->
ldo_tm_net
)
!=
0
)
{
return
LDAP_OPT_ERROR
;
}
*
(
struct
timeval
*
)
outvalue
=
lo
->
ldo_tm_net
;
return
LDAP_OPT_SUCCESS
;
case
LDAP_OPT_DEREF
:
...
...
@@ -452,28 +446,14 @@ ldap_set_option(
const
struct
timeval
*
tv
=
(
const
struct
timeval
*
)
invalue
;
if
(
lo
->
ldo_tm_api
!=
NULL
)
{
LDAP_FREE
(
lo
->
ldo_tm_api
);
lo
->
ldo_tm_api
=
NULL
;
}
if
(
ldap_int_timeval_dup
(
&
lo
->
ldo_tm_api
,
tv
)
!=
0
)
{
return
LDAP_OPT_ERROR
;
}
lo
->
ldo_tm_api
=
*
tv
;
}
return
LDAP_OPT_SUCCESS
;
case
LDAP_OPT_NETWORK_TIMEOUT
:
{
const
struct
timeval
*
tv
=
(
const
struct
timeval
*
)
invalue
;
if
(
lo
->
ldo_tm_net
!=
NULL
)
{
LDAP_FREE
(
lo
->
ldo_tm_net
);
lo
->
ldo_tm_net
=
NULL
;
}
if
(
ldap_int_timeval_dup
(
&
lo
->
ldo_tm_net
,
tv
)
!=
0
)
{
return
LDAP_OPT_ERROR
;
}
lo
->
ldo_tm_net
=
*
tv
;
}
return
LDAP_OPT_SUCCESS
;
case
LDAP_OPT_HOST_NAME
:
{
...
...
libraries/libldap/os-ip.c
View file @
0c542682
...
...
@@ -354,8 +354,7 @@ ldap_pvt_connect(LDAP *ld, ber_socket_t s,
int
async
)
{
int
rc
,
err
;
struct
timeval
tv
=
{
0
},
*
opt_tv
=
NULL
;
struct
timeval
tv
,
*
opt_tv
=
NULL
;
#ifdef LDAP_CONNECTIONLESS
/* We could do a connect() but that would interfere with
...
...
@@ -369,9 +368,9 @@ ldap_pvt_connect(LDAP *ld, ber_socket_t s,
return
(
0
);
}
#endif
opt_tv
=
ld
->
ld_options
.
ldo_tm_net
;
if
(
opt_tv
!=
NULL
)
{
tv
=
*
opt_
tv
;
if
(
ld
->
ld_options
.
ldo_tm_net
.
tv_sec
>=
0
)
{
tv
=
ld
->
ld_options
.
ldo_tm_net
;
opt_
tv
=
&
tv
;
}
osip_debug
(
ld
,
"ldap_pvt_connect: fd: %d tm: %ld async: %d
\n
"
,
...
...
libraries/libldap/os-local.c
View file @
0c542682
...
...
@@ -168,12 +168,11 @@ static int
ldap_pvt_connect
(
LDAP
*
ld
,
ber_socket_t
s
,
struct
sockaddr_un
*
sa
,
int
async
)
{
int
rc
;
struct
timeval
tv
=
{
0
},
*
opt_tv
=
NULL
;
struct
timeval
tv
,
*
opt_tv
=
NULL
;
opt_tv
=
ld
->
ld_options
.
ldo_tm_net
;
if
(
opt_tv
!=
NULL
)
{
tv
=
*
opt_
tv
;
if
(
ld
->
ld_options
.
ldo_tm_net
.
tv_sec
>=
0
)
{
tv
=
ld
->
ld_options
.
ldo_tm_net
;
opt_
tv
=
&
tv
;
}
oslocal_debug
(
ld
,
"ldap_connect_timeout: fd: %d tm: %ld async: %d
\n
"
,
...
...
libraries/libldap/request.c
View file @
0c542682
...
...
@@ -223,18 +223,16 @@ ldap_send_server_request(
lc
->
lconn_status
=
LDAP_CONNST_CONNECTED
;
break
;
case
-
2
:
{
case
-
2
:
/* async only occurs if a network timeout is set */
struct
timeval
*
tvp
=
ld
->
ld_options
.
ldo_tm_net
;
assert
(
tvp
!=
NULL
);
/* honor network timeout */
if
(
time
(
NULL
)
-
lc
->
lconn_created
<=
tvp
->
tv_sec
)
{
/* caller will have to call again */
ld
->
ld_errno
=
LDAP_X_CONNECTING
;
}
}
/* fallthru */
/* honor network timeout */
if
(
time
(
NULL
)
-
lc
->
lconn_created
<=
ld
->
ld_options
.
ldo_tm_net
.
tv_sec
)
{
/* caller will have to call again */
ld
->
ld_errno
=
LDAP_X_CONNECTING
;
}
/* fallthru */
default:
/* error */
...
...
libraries/libldap/result.c
View file @
0c542682
...
...
@@ -275,8 +275,9 @@ wait4msg(
LDAP_PVT_THREAD_ASSERT_MUTEX_OWNER
(
&
ld
->
ld_res_mutex
);
#endif
if
(
timeout
==
NULL
)
{
timeout
=
ld
->
ld_options
.
ldo_tm_api
;
if
(
timeout
==
NULL
&&
ld
->
ld_options
.
ldo_tm_api
.
tv_sec
>=
0
)
{
tv
=
ld
->
ld_options
.
ldo_tm_api
;
timeout
=
&
tv
;
}
#ifdef LDAP_DEBUG
...
...
libraries/libldap/unbind.c
View file @
0c542682
...
...
@@ -144,16 +144,6 @@ ldap_ld_free(
}
#endif
if
(
ld
->
ld_options
.
ldo_tm_api
!=
NULL
)
{
LDAP_FREE
(
ld
->
ld_options
.
ldo_tm_api
);
ld
->
ld_options
.
ldo_tm_api
=
NULL
;
}
if
(
ld
->
ld_options
.
ldo_tm_net
!=
NULL
)
{
LDAP_FREE
(
ld
->
ld_options
.
ldo_tm_net
);
ld
->
ld_options
.
ldo_tm_net
=
NULL
;
}
#ifdef HAVE_CYRUS_SASL
if
(
ld
->
ld_options
.
ldo_def_sasl_mech
!=
NULL
)
{
LDAP_FREE
(
ld
->
ld_options
.
ldo_def_sasl_mech
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment