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
4c355deb
Commit
4c355deb
authored
Mar 16, 2018
by
Ondřej Kuzník
Browse files
Record the backend name
parent
3a6b3995
Changes
4
Hide whitespace changes
Inline
Side-by-side
servers/lloadd/backend.c
View file @
4c355deb
...
...
@@ -510,6 +510,7 @@ lload_backend_destroy( LloadBackend *b )
ch_free
(
b
->
b_host
);
ch_free
(
b
->
b_uri
.
bv_val
);
ch_free
(
b
->
b_name
.
bv_val
);
ch_free
(
b
);
}
...
...
servers/lloadd/config.c
View file @
4c355deb
...
...
@@ -1085,7 +1085,7 @@ config_bindconf( ConfigArgs *c )
lload_bindconf_unparse
(
&
bindconf
,
&
bv
);
for
(
i
=
0
;
isspace
((
unsigned
char
)
bv
.
bv_val
[
i
]);
i
++
)
for
(
i
=
0
;
isspace
(
(
unsigned
char
)
bv
.
bv_val
[
i
]
);
i
++
)
/* count spaces */
;
if
(
i
)
{
...
...
@@ -3563,6 +3563,11 @@ static int
lload_backend_ldadd
(
CfEntryInfo
*
p
,
Entry
*
e
,
ConfigArgs
*
ca
)
{
LloadBackend
*
b
;
Attribute
*
a
;
AttributeDescription
*
ad
=
NULL
;
struct
berval
bv
,
type
,
rdn
;
const
char
*
text
;
char
*
name
;
Debug
(
LDAP_DEBUG_TRACE
,
"lload_backend_ldadd: "
"a new backend-server is being added
\n
"
);
...
...
@@ -3571,7 +3576,26 @@ lload_backend_ldadd( CfEntryInfo *p, Entry *e, ConfigArgs *ca )
p
->
ce_bi
->
bi_cf_ocs
!=
lloadocs
)
return
LDAP_CONSTRAINT_VIOLATION
;
dnRdn
(
&
e
->
e_name
,
&
rdn
);
type
.
bv_len
=
strchr
(
rdn
.
bv_val
,
'='
)
-
rdn
.
bv_val
;
type
.
bv_val
=
rdn
.
bv_val
;
/* Find attr */
slap_bv2ad
(
&
type
,
&
ad
,
&
text
);
if
(
ad
!=
slap_schema
.
si_ad_cn
)
return
LDAP_NAMING_VIOLATION
;
a
=
attr_find
(
e
->
e_attrs
,
ad
);
if
(
!
a
||
a
->
a_numvals
!=
1
)
return
LDAP_NAMING_VIOLATION
;
bv
=
a
->
a_vals
[
0
];
if
(
bv
.
bv_val
[
0
]
==
'{'
&&
(
name
=
strchr
(
bv
.
bv_val
,
'}'
)
)
)
{
name
++
;
bv
.
bv_len
-=
name
-
bv
.
bv_val
;
bv
.
bv_val
=
name
;
}
b
=
backend_alloc
();
ber_dupbv
(
&
b
->
b_name
,
&
bv
);
ca
->
bi
=
p
->
ce_bi
;
ca
->
ca_private
=
b
;
...
...
@@ -3611,9 +3635,14 @@ lload_cfadd( Operation *op, SlapReply *rs, Entry *p, ConfigArgs *c )
bv
.
bv_val
=
c
->
cr_msg
;
LDAP_CIRCLEQ_FOREACH
(
b
,
&
backend
,
b_next
)
{
char
buf
[
STRLENOF
(
"server 4294967295"
)
+
1
]
=
{
0
};
bv
.
bv_len
=
snprintf
(
c
->
cr_msg
,
sizeof
(
c
->
cr_msg
),
"cn="
SLAP_X_ORDERED_FMT
"server %d"
,
i
,
i
+
1
);
snprintf
(
buf
,
sizeof
(
buf
),
"server %d"
,
i
+
1
);
ber_str2bv
(
buf
,
0
,
1
,
&
b
->
b_name
);
c
->
ca_private
=
b
;
c
->
valx
=
i
;
...
...
servers/lloadd/lload.h
View file @
4c355deb
...
...
@@ -188,7 +188,7 @@ typedef struct lload_global_stats_t {
struct
LloadBackend
{
ldap_pvt_thread_mutex_t
b_mutex
;
struct
berval
b_uri
;
struct
berval
b_name
,
b_uri
;
int
b_proto
,
b_port
;
enum
lload_tls_type
b_tls
;
char
*
b_host
;
...
...
servers/lloadd/monitor.c
View file @
4c355deb
...
...
@@ -687,9 +687,6 @@ done:
return
rc
;
}
static
struct
monitor_subsys_t
*
servers_subsys
;
/* Not sure if this has to be a subsystem at all, perhaps just entries? */
static
int
lload_monitor_server_update
(
Operation
*
op
,
...
...
@@ -816,7 +813,6 @@ lload_monitor_backends_init( BackendDB *be, monitor_subsys_t *ms )
{
monitor_extra_t
*
mbe
;
Entry
*
e
;
unsigned
int
i
=
1
,
j
=
0
;
int
rc
;
LloadBackend
*
b
;
...
...
@@ -847,22 +843,15 @@ lload_monitor_backends_init( BackendDB *be, monitor_subsys_t *ms )
}
LDAP_CIRCLEQ_FOREACH
(
b
,
&
backend
,
b_next
)
{
j
++
;
}
servers_subsys
=
ch_calloc
(
j
,
sizeof
(
monitor_subsys_t
)
);
LDAP_CIRCLEQ_FOREACH
(
b
,
&
backend
,
b_next
)
{
monitor_subsys_t
*
bk_mss
;
struct
berval
bv
;
monitor_subsys_t
*
bk_mss
=
ch_calloc
(
1
,
sizeof
(
monitor_subsys_t
)
);
bv
.
bv_len
=
sizeof
(
"cn=Server 4294967295"
);
bv
.
bv_val
=
ch_malloc
(
bv
.
bv_len
);
bv
.
bv_len
=
snprintf
(
bv
.
bv_val
,
bv
.
bv_len
,
"cn=Server %u"
,
i
);
bk_mss
->
mss_rdn
.
bv_len
=
sizeof
(
"cn="
)
+
b
->
b_name
.
bv_len
;
bk_mss
->
mss_rdn
.
bv_val
=
ch_malloc
(
bk_mss
->
mss_rdn
.
bv_len
);
bk_mss
->
mss_rdn
.
bv_len
=
snprintf
(
bk_mss
->
mss_rdn
.
bv_val
,
bk_mss
->
mss_rdn
.
bv_len
,
"cn=%s"
,
b
->
b_name
.
bv_val
);
bk_mss
=
&
servers_subsys
[
i
-
1
];
bk_mss
->
mss_name
=
bv
.
bv_val
;
ber_str2bv
(
LLOAD_MONITOR_BACKENDS_DN
,
0
,
0
,
&
bk_mss
->
mss_dn
);
b
er_dupbv
(
&
bk_mss
->
mss_rdn
,
&
bv
)
;
b
k_mss
->
mss_name
=
b
->
b_name
.
bv_val
;
bk_mss
->
mss_flags
=
MONITOR_F_VOLATILE_CH
;
bk_mss
->
mss_open
=
lload_monitor_backend_open
;
bk_mss
->
mss_create
=
lload_monitor_up_conn_create
;
...
...
@@ -876,7 +865,6 @@ lload_monitor_backends_init( BackendDB *be, monitor_subsys_t *ms )
bk_mss
->
mss_name
);
return
-
1
;
}
i
++
;
}
done:
entry_free
(
e
);
...
...
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