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
bf9f99dd
Commit
bf9f99dd
authored
Feb 19, 2018
by
Ondřej Kuzník
Browse files
Split backend destruction from resetting it
parent
7f22bac4
Changes
3
Hide whitespace changes
Inline
Side-by-side
servers/lloadd/backend.c
View file @
bf9f99dd
...
...
@@ -433,71 +433,92 @@ backend_connect_task( void *ctx, void *arg )
}
void
backend
s_destroy
(
void
)
backend
_reset
(
LloadBackend
*
b
)
{
while
(
!
LDAP_
CIRCLEQ
_EMPTY
(
&
b
ackend
)
)
{
Lload
Backend
*
b
=
LDAP_
CIRCLEQ
_FIRST
(
&
b
ackend
);
while
(
!
LDAP_
LIST
_EMPTY
(
&
b
->
b_connecting
)
)
{
Lload
PendingConnection
*
pending
=
LDAP_
LIST
_FIRST
(
&
b
->
b_connecting
);
Debug
(
LDAP_DEBUG_CONNS
,
"backend
s_destroy
: "
"destroying
ba
cke
nd uri='%s', numconns=%d, numbindconns
=%d
\n
"
,
b
->
b_uri
.
bv_val
,
b
->
b_numconns
,
b
->
b_numbindconns
);
Debug
(
LDAP_DEBUG_CONNS
,
"backend
_reset
: "
"destroying
so
cke
t pending connect() fd
=%d
\n
"
,
pending
->
fd
);
while
(
!
LDAP_LIST_EMPTY
(
&
b
->
b_connecting
)
)
{
LloadPendingConnection
*
pending
=
LDAP_LIST_FIRST
(
&
b
->
b_connecting
);
event_free
(
pending
->
event
);
evutil_closesocket
(
pending
->
fd
);
LDAP_LIST_REMOVE
(
pending
,
next
);
ch_free
(
pending
);
}
while
(
!
LDAP_CIRCLEQ_EMPTY
(
&
b
->
b_preparing
)
)
{
LloadConnection
*
c
=
LDAP_CIRCLEQ_FIRST
(
&
b
->
b_preparing
);
Debug
(
LDAP_DEBUG_CONNS
,
"backends_destroy: "
"destroying socket pending connect() fd=%d
\n
"
,
pending
->
fd
);
CONNECTION_LOCK
(
c
);
Debug
(
LDAP_DEBUG_CONNS
,
"backend_reset: "
"destroying connection being set up connid=%lu
\n
"
,
c
->
c_connid
);
event_free
(
pending
->
event
);
evutil_closesocket
(
pending
->
fd
);
LDAP_LIST_REMOVE
(
pending
,
next
);
ch_free
(
pending
);
}
while
(
!
LDAP_CIRCLEQ_EMPTY
(
&
b
->
b_preparing
)
)
{
LloadConnection
*
c
=
LDAP_CIRCLEQ_FIRST
(
&
b
->
b_preparing
);
assert
(
c
->
c_live
);
CONNECTION_DESTROY
(
c
);
assert
(
!
c
);
}
while
(
!
LDAP_CIRCLEQ_EMPTY
(
&
b
->
b_bindconns
)
)
{
LloadConnection
*
c
=
LDAP_CIRCLEQ_FIRST
(
&
b
->
b_bindconns
);
CONNECTION_LOCK
(
c
);
Debug
(
LDAP_DEBUG_CONNS
,
"backend
s_destroy
: "
"destroying connection
being set up connid=%lu
\n
"
,
c
->
c_connid
);
CONNECTION_LOCK
(
c
);
Debug
(
LDAP_DEBUG_CONNS
,
"backend
_reset
: "
"destroying
bind
connection
connid=%lu, pending ops=%ld
\n
"
,
c
->
c_connid
,
c
->
c_n_ops_executing
);
assert
(
c
->
c_live
);
CONNECTION_DESTROY
(
c
);
}
while
(
!
LDAP_CIRCLEQ_EMPTY
(
&
b
->
b_bindconns
)
)
{
LloadConnection
*
c
=
LDAP_CIRCLEQ_FIRST
(
&
b
->
b_bindconns
);
assert
(
c
->
c_live
);
CONNECTION_DESTROY
(
c
);
assert
(
!
c
);
}
while
(
!
LDAP_CIRCLEQ_EMPTY
(
&
b
->
b_conns
)
)
{
LloadConnection
*
c
=
LDAP_CIRCLEQ_FIRST
(
&
b
->
b_conns
);
CONNECTION_LOCK
(
c
);
Debug
(
LDAP_DEBUG_CONNS
,
"backend
s_destroy
: "
"destroying
bind
connection connid=%lu, pending ops=%ld
\n
"
,
c
->
c_connid
,
c
->
c_n_ops_executing
);
CONNECTION_LOCK
(
c
);
Debug
(
LDAP_DEBUG_CONNS
,
"backend
_reset
: "
"destroying
regular
connection connid=%lu, pending ops=%ld
\n
"
,
c
->
c_connid
,
c
->
c_n_ops_executing
);
assert
(
c
->
c_live
);
CONNECTION_DESTROY
(
c
);
}
while
(
!
LDAP_CIRCLEQ_EMPTY
(
&
b
->
b_conns
)
)
{
LloadConnection
*
c
=
LDAP_CIRCLEQ_FIRST
(
&
b
->
b_conns
);
assert
(
c
->
c_live
);
CONNECTION_DESTROY
(
c
);
assert
(
!
c
);
}
}
CONNECTION_LOCK
(
c
);
Debug
(
LDAP_DEBUG_CONNS
,
"backends_destroy: "
"destroying regular connection connid=%lu, pending "
"ops=%ld
\n
"
,
c
->
c_connid
,
c
->
c_n_ops_executing
);
void
lload_backend_destroy
(
LloadBackend
*
b
)
{
LloadBackend
*
next
=
LDAP_CIRCLEQ_LOOP_NEXT
(
&
backend
,
b
,
b_next
);
assert
(
c
->
c_live
);
CONNECTION_DESTROY
(
c
);
}
Debug
(
LDAP_DEBUG_CONNS
,
"lload_backend_destroy: "
"destroying backend uri='%s', numconns=%d, numbindconns=%d
\n
"
,
b
->
b_uri
.
bv_val
,
b
->
b_numconns
,
b
->
b_numbindconns
);
backend_reset
(
b
);
LDAP_CIRCLEQ_REMOVE
(
&
backend
,
b
,
b_next
);
if
(
b
==
next
)
{
current_backend
=
NULL
;
}
else
{
current_backend
=
next
;
}
ldap_pvt_thread_mutex_destroy
(
&
b
->
b_mutex
);
LDAP_CIRCLEQ_REMOVE
(
&
backend
,
b
,
b_nex
t
);
ldap_pvt_thread_mutex_destroy
(
&
b
->
b_
mutex
);
event_del
(
b
->
b_retry_even
t
);
event_free
(
b
->
b_
retry_event
);
event_del
(
b
->
b_retry_event
);
event_free
(
b
->
b_retry_event
);
ch_free
(
b
->
b_host
);
ch_free
(
b
->
b_uri
.
bv_val
);
ch_free
(
b
);
}
void
lload_backends_destroy
(
void
)
{
while
(
!
LDAP_CIRCLEQ_EMPTY
(
&
backend
)
)
{
LloadBackend
*
b
=
LDAP_CIRCLEQ_FIRST
(
&
backend
);
ch_free
(
b
->
b_host
);
ch_free
(
b
->
b_uri
.
bv_val
);
ch_free
(
b
);
lload_backend_destroy
(
b
);
}
}
servers/lloadd/daemon.c
View file @
bf9f99dd
...
...
@@ -1367,7 +1367,7 @@ lloadd_daemon( struct event_base *daemon_base )
t
);
}
ldap_pvt_thread_pool_close
(
&
connection_pool
,
1
);
backends_destroy
();
lload_
backends_destroy
();
clients_destroy
();
lload_bindconf_free
(
&
bindconf
);
evdns_base_free
(
dnsbase
,
0
);
...
...
servers/lloadd/proto-lload.h
View file @
bf9f99dd
...
...
@@ -41,7 +41,9 @@ LDAP_SLAPD_F (void) backend_connect( evutil_socket_t s, short what, void *arg );
LDAP_SLAPD_F
(
void
*
)
backend_connect_task
(
void
*
ctx
,
void
*
arg
);
LDAP_SLAPD_F
(
void
)
backend_retry
(
LloadBackend
*
b
);
LDAP_SLAPD_F
(
LloadConnection
*
)
backend_select
(
LloadOperation
*
op
,
int
*
res
);
LDAP_SLAPD_F
(
void
)
backends_destroy
(
void
);
LDAP_SLAPD_F
(
void
)
backend_reset
(
LloadBackend
*
b
);
LDAP_SLAPD_F
(
void
)
lload_backend_destroy
(
LloadBackend
*
b
);
LDAP_SLAPD_F
(
void
)
lload_backends_destroy
(
void
);
/*
* bind.c
...
...
Write
Preview
Markdown
is supported
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