Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
ingo Voss
OpenLDAP
Commits
8c16d300
Commit
8c16d300
authored
Nov 13, 2001
by
Mark Adamson
Browse files
optimize number of calls to slap_get_time()
parent
52d3f7b3
Changes
4
Hide whitespace changes
Inline
Side-by-side
servers/slapd/back-ldbm/dbcache.c
View file @
8c16d300
...
...
@@ -28,7 +28,7 @@ ldbm_cache_open(
{
struct
ldbminfo
*
li
=
(
struct
ldbminfo
*
)
be
->
be_private
;
int
i
,
lru
,
empty
;
time_t
oldtime
,
curtime
;
time_t
oldtime
;
char
buf
[
MAXPATHLEN
];
#ifdef HAVE_ST_BLKSIZE
struct
stat
st
;
...
...
@@ -61,13 +61,12 @@ ldbm_cache_open(
#endif
curtime
=
slap_get_time
();
empty
=
MAXDBCACHE
;
ldap_pvt_thread_mutex_lock
(
&
li
->
li_dbcache_mutex
);
do
{
lru
=
0
;
oldtime
=
curtime
;
oldtime
=
1
;
for
(
i
=
0
;
i
<
MAXDBCACHE
;
i
++
)
{
/* see if this slot is free */
if
(
li
->
li_dbcache
[
i
].
dbc_name
==
NULL
)
{
...
...
@@ -113,8 +112,9 @@ ldbm_cache_open(
}
/* keep track of lru db */
if
(
li
->
li_dbcache
[
i
].
dbc_lastref
<
oldtime
&&
li
->
li_dbcache
[
i
].
dbc_refcnt
==
0
)
if
((
li
->
li_dbcache
[
i
].
dbc_refcnt
==
0
)
&&
((
oldtime
==
1
)
||
(
li
->
li_dbcache
[
i
].
dbc_lastref
<
oldtime
))
)
{
lru
=
i
;
oldtime
=
li
->
li_dbcache
[
i
].
dbc_lastref
;
...
...
@@ -170,7 +170,7 @@ ldbm_cache_open(
}
li
->
li_dbcache
[
i
].
dbc_name
=
ch_strdup
(
buf
);
li
->
li_dbcache
[
i
].
dbc_refcnt
=
1
;
li
->
li_dbcache
[
i
].
dbc_lastref
=
cur
time
;
li
->
li_dbcache
[
i
].
dbc_lastref
=
slap_get_
time
()
;
li
->
li_dbcache
[
i
].
dbc_flags
=
flags
;
li
->
li_dbcache
[
i
].
dbc_dirty
=
0
;
#ifdef HAVE_ST_BLKSIZE
...
...
servers/slapd/back-ldbm/search.c
View file @
8c16d300
...
...
@@ -299,7 +299,7 @@ searchit:
ldap_pvt_thread_mutex_unlock
(
&
op
->
o_abandonmutex
);
/* check time limit */
if
(
tlimit
!=
-
1
&&
slap_get_time
()
>
stoptime
)
{
if
(
tlimit
!=
-
1
&&
(
ID_BLOCK_NIDS
(
candidates
)
>
2
)
&&
slap_get_time
()
>
stoptime
)
{
send_search_result
(
conn
,
op
,
LDAP_TIMELIMIT_EXCEEDED
,
NULL
,
NULL
,
v2refs
,
NULL
,
nentries
);
rc
=
0
;
...
...
servers/slapd/connection.c
View file @
8c16d300
...
...
@@ -300,7 +300,13 @@ static Connection* connection_get( ber_socket_t s )
assert
(
c
->
c_conn_state
!=
SLAP_C_INVALID
);
assert
(
sd
!=
AC_SOCKET_INVALID
);
c
->
c_activitytime
=
slap_get_time
();
#ifdef SLAPD_MONITOR
c
->
c_activitytime
=
slap_get_time
();
#else
if
(
global_idletimeout
>
0
)
{
c
->
c_activitytime
=
slap_get_time
();
}
#endif
}
return
c
;
...
...
@@ -474,7 +480,13 @@ long connection_init(
/* set to zero until bind, implies LDAP_VERSION3 */
c
->
c_protocol
=
0
;
c
->
c_activitytime
=
c
->
c_starttime
=
slap_get_time
();
#ifdef SLAPD_MONITOR
c
->
c_activitytime
=
c
->
c_starttime
=
slap_get_time
();
#else
if
(
global_idletimeout
>
0
)
{
c
->
c_activitytime
=
c
->
c_starttime
=
slap_get_time
();
}
#endif
#ifdef LDAP_CONNECTIONLESS
c
->
c_is_udp
=
0
;
...
...
servers/slapd/daemon.c
View file @
8c16d300
...
...
@@ -940,9 +940,12 @@ slapd_daemon_task(
)
{
int
l
;
time_t
last_idle_check
=
slap_get_time
()
;
time_t
last_idle_check
;
time
(
&
starttime
);
if
(
global_idletimeout
>
0
)
{
last_idle_check
=
slap_get_time
();
}
for
(
l
=
0
;
slap_listeners
[
l
]
!=
NULL
;
l
++
)
{
if
(
slap_listeners
[
l
]
->
sl_sd
==
AC_SOCKET_INVALID
)
continue
;
...
...
@@ -993,7 +996,7 @@ slapd_daemon_task(
int
emfile
=
0
;
#define SLAPD_IDLE_CHECK_LIMIT 4
time_t
now
=
slap_get_time
()
;
time_t
now
;
fd_set
readfds
;
...
...
@@ -1006,11 +1009,15 @@ slapd_daemon_task(
struct
timeval
zero
;
struct
timeval
*
tvp
;
if
(
emfile
||
(
global_idletimeout
>
0
&&
difftime
(
last_idle_check
+
global_idletimeout
/
SLAPD_IDLE_CHECK_LIMIT
,
now
)
<
0
))
{
connections_timeout_idle
(
now
);
if
(
emfile
)
{
now
=
slap_get_time
();
connections_timeout_idle
(
now
);
}
else
if
(
global_idletimeout
>
0
)
{
now
=
slap_get_time
();
if
(
difftime
(
last_idle_check
+
global_idletimeout
/
SLAPD_IDLE_CHECK_LIMIT
,
now
)
<
0
)
{
connections_timeout_idle
(
now
);
}
}
FD_ZERO
(
&
writefds
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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