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
Joe Martin
OpenLDAP
Commits
58a880bc
Commit
58a880bc
authored
May 10, 2017
by
Ondřej Kuzník
Committed by
Ondřej Kuzník
Nov 17, 2020
Browse files
Convert backend and upstream management to use CIRCLEQ.
This alone doesn't make the server do a round robin.
parent
643194e7
Changes
6
Hide whitespace changes
Inline
Side-by-side
servers/lloadd/backend.c
View file @
58a880bc
...
...
@@ -97,7 +97,7 @@ backend_select( Operation *op )
/* TODO: Two runs, one with trylock, then one actually locked if we don't
* find anything? */
LDAP_
STAIL
Q_FOREACH
(
b
,
&
backend
,
b_next
)
{
LDAP_
CIRCLE
Q_FOREACH
(
b
,
&
backend
,
b_next
)
{
struct
ConnSt
*
head
;
Connection
*
c
;
...
...
@@ -118,10 +118,7 @@ backend_select( Operation *op )
head
=
&
b
->
b_conns
;
}
/* TODO: Use CIRCLEQ so that we can do a natural round robin over the
* backend's connections? */
LDAP_LIST_FOREACH
(
c
,
head
,
c_next
)
{
LDAP_CIRCLEQ_FOREACH
(
c
,
head
,
c_next
)
{
ldap_pvt_thread_mutex_lock
(
&
c
->
c_io_mutex
);
CONNECTION_LOCK
(
c
);
if
(
c
->
c_state
==
SLAP_C_READY
&&
!
c
->
c_pendingber
&&
...
...
@@ -284,25 +281,25 @@ backend_connect_task( void *ctx, void *arg )
void
backends_destroy
(
void
)
{
Backend
*
b
;
while
(
(
b
=
LDAP_STAILQ_FIRST
(
&
backend
))
)
{
Connection
*
c
;
while
(
!
LDAP_CIRCLEQ_EMPTY
(
&
backend
)
)
{
Backend
*
b
=
LDAP_CIRCLEQ_FIRST
(
&
backend
);
Debug
(
LDAP_DEBUG_CONNS
,
"backends_destroy: "
"destroying backend uri='%s', numconns=%d, numbindconns=%d
\n
"
,
b
->
b_bindconf
.
sb_uri
.
bv_val
,
b
->
b_numconns
,
b
->
b_numbindconns
);
while
(
(
c
=
LDAP_LIST_FIRST
(
&
b
->
b_bindconns
))
)
{
while
(
!
LDAP_CIRCLEQ_EMPTY
(
&
b
->
b_bindconns
)
)
{
Connection
*
c
=
LDAP_CIRCLEQ_FIRST
(
&
b
->
b_bindconns
);
CONNECTION_LOCK
(
c
);
UPSTREAM_DESTROY
(
c
);
}
while
(
(
c
=
LDAP_LIST_FIRST
(
&
b
->
b_conns
))
)
{
while
(
!
LDAP_CIRCLEQ_EMPTY
(
&
b
->
b_conns
)
)
{
Connection
*
c
=
LDAP_CIRCLEQ_FIRST
(
&
b
->
b_conns
);
CONNECTION_LOCK
(
c
);
UPSTREAM_DESTROY
(
c
);
}
LDAP_
STAIL
Q_REMOVE
_HEAD
(
&
backend
,
b_next
);
LDAP_
CIRCLE
Q_REMOVE
(
&
backend
,
b
,
b_next
);
ldap_pvt_thread_mutex_destroy
(
&
b
->
b_mutex
);
event_del
(
b
->
b_retry_event
);
...
...
servers/lloadd/config.c
View file @
58a880bc
...
...
@@ -112,7 +112,7 @@ static ConfigDriver config_tls_option;
static
ConfigDriver
config_tls_config
;
#endif
slap_b_head
backend
=
LDAP_
STAIL
Q_HEAD_INITIALIZER
(
backend
);
slap_b_head
backend
=
LDAP_
CIRCLE
Q_HEAD_INITIALIZER
(
backend
);
enum
{
CFG_ACL
=
1
,
...
...
@@ -462,8 +462,8 @@ config_backend( ConfigArgs *c )
b
=
ch_calloc
(
1
,
sizeof
(
Backend
)
);
LDAP_
LIST
_INIT
(
&
b
->
b_conns
);
LDAP_
LIST
_INIT
(
&
b
->
b_bindconns
);
LDAP_
CIRCLEQ
_INIT
(
&
b
->
b_conns
);
LDAP_
CIRCLEQ
_INIT
(
&
b
->
b_bindconns
);
b
->
b_numconns
=
1
;
b
->
b_numbindconns
=
1
;
...
...
@@ -595,7 +595,7 @@ done:
if
(
rc
)
{
ch_free
(
b
);
}
else
{
LDAP_
STAIL
Q_INSERT_TAIL
(
&
backend
,
b
,
b_next
);
LDAP_
CIRCLE
Q_INSERT_TAIL
(
&
backend
,
b
,
b_next
);
}
return
rc
;
...
...
servers/lloadd/connection.c
View file @
58a880bc
...
...
@@ -155,7 +155,7 @@ connection_init( ber_socket_t s, const char *peername, int flags )
c
->
c_next_msgid
=
1
;
c
->
c_refcnt
=
c
->
c_live
=
1
;
LDAP_
LIST
_ENTRY_INIT
(
c
,
c_next
);
LDAP_
CIRCLEQ
_ENTRY_INIT
(
c
,
c_next
);
ldap_pvt_thread_mutex_init
(
&
c
->
c_mutex
);
ldap_pvt_thread_mutex_init
(
&
c
->
c_io_mutex
);
...
...
servers/lloadd/daemon.c
View file @
58a880bc
...
...
@@ -1313,7 +1313,7 @@ slapd_daemon( struct event_base *daemon_base )
}
}
LDAP_
STAIL
Q_FOREACH
(
b
,
&
backend
,
b_next
)
{
LDAP_
CIRCLE
Q_FOREACH
(
b
,
&
backend
,
b_next
)
{
struct
event
*
retry_event
=
evtimer_new
(
daemon_base
,
backend_connect
,
b
);
...
...
servers/lloadd/slap.h
View file @
58a880bc
...
...
@@ -121,7 +121,7 @@ typedef union Sockaddr {
extern
int
slap_inet4or6
;
#endif
typedef
LDAP_
STAIL
Q_HEAD
(
BeSt
,
Backend
)
slap_b_head
;
typedef
LDAP_
CIRCLE
Q_HEAD
(
BeSt
,
Backend
)
slap_b_head
;
LDAP_SLAPD_V
(
slap_b_head
)
backend
;
...
...
@@ -253,12 +253,12 @@ struct Backend {
int
b_numconns
,
b_numbindconns
;
int
b_bindavail
,
b_active
,
b_opening
;
LDAP_
LIST
_HEAD
(
ConnSt
,
Connection
)
b_conns
,
b_bindconns
;
LDAP_
CIRCLEQ
_HEAD
(
ConnSt
,
Connection
)
b_conns
,
b_bindconns
;
long
b_max_pending
,
b_max_conn_pending
;
long
b_n_ops_executing
;
LDAP_
STAIL
Q_ENTRY
(
Backend
)
b_next
;
LDAP_
CIRCLE
Q_ENTRY
(
Backend
)
b_next
;
};
typedef
int
(
*
OperationHandler
)(
Operation
*
op
,
BerElement
*
ber
);
...
...
@@ -393,7 +393,7 @@ struct Connection {
long
c_n_ops_completed
;
/* num of ops completed */
/* Upstream: Protected by its backend's mutex */
LDAP_
LIST
_ENTRY
(
Connection
)
c_next
;
LDAP_
CIRCLEQ
_ENTRY
(
Connection
)
c_next
;
void
*
c_private
;
};
...
...
servers/lloadd/upstream.c
View file @
58a880bc
...
...
@@ -845,11 +845,11 @@ upstream_init( ber_socket_t s, Backend *b )
}
if
(
is_bindconn
)
{
LDAP_
LIST
_INSERT_HEAD
(
&
b
->
b_bindconns
,
c
,
c_next
);
LDAP_
CIRCLEQ
_INSERT_HEAD
(
&
b
->
b_bindconns
,
c
,
c_next
);
c
->
c_type
=
SLAP_C_BIND
;
b
->
b_bindavail
++
;
}
else
{
LDAP_
LIST
_INSERT_HEAD
(
&
b
->
b_conns
,
c
,
c_next
);
LDAP_
CIRCLEQ
_INSERT_HEAD
(
&
b
->
b_conns
,
c
,
c_next
);
b
->
b_active
++
;
}
...
...
@@ -899,10 +899,11 @@ upstream_destroy( Connection *c )
}
ldap_pvt_thread_mutex_lock
(
&
b
->
b_mutex
);
LDAP_LIST_REMOVE
(
c
,
c_next
);
if
(
c
->
c_type
==
SLAP_C_BIND
)
{
LDAP_CIRCLEQ_REMOVE
(
&
b
->
b_bindconns
,
c
,
c_next
);
b
->
b_bindavail
--
;
}
else
{
LDAP_CIRCLEQ_REMOVE
(
&
b
->
b_conns
,
c
,
c_next
);
b
->
b_active
--
;
}
b
->
b_n_ops_executing
-=
c
->
c_n_ops_executing
;
...
...
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