Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Tero Saarni
OpenLDAP
Commits
296ac170
Commit
296ac170
authored
Apr 21, 2008
by
Quanah Gibson-Mount
Browse files
ITS
#5470
parent
6318606b
Changes
2
Hide whitespace changes
Inline
Side-by-side
CHANGES
View file @
296ac170
...
...
@@ -21,6 +21,7 @@ OpenLDAP 2.4.9 Engineering
Fixed slapd syncrepl crash on empty CSN (ITS#5432)
Fixed slapd syncrepl refreshAndPersist (ITS#5454)
Fixed slapd syncrepl modrdn processing (ITS#5397)
Fixed slapd syncrepl MMR partial refresh (ITS#5470)
Fixed slapd value list termination (ITS#5450)
Fixed slapd/slapo-accesslog rq mutex usage (ITS#5442)
Fixed slapd-bdb ID_NOCACHE handling (ITS#5439)
...
...
servers/slapd/syncrepl.c
View file @
296ac170
...
...
@@ -432,6 +432,112 @@ ldap_sync_search(
return
rc
;
}
static
int
check_syncprov
(
Operation
*
op
,
syncinfo_t
*
si
)
{
AttributeName
at
[
2
];
Attribute
a
=
{
0
};
Entry
e
=
{
0
};
SlapReply
rs
=
{
0
};
int
i
,
j
,
changed
=
0
;
/* Look for contextCSN from syncprov overlay. If
* there's no overlay, this will be a no-op. That means
* this is a pure consumer, so local changes will not be
* allowed, and all changes will already be reflected in
* the cookieState.
*/
a
.
a_desc
=
slap_schema
.
si_ad_contextCSN
;
e
.
e_attrs
=
&
a
;
e
.
e_name
=
op
->
o_bd
->
be_suffix
[
0
];
e
.
e_nname
=
op
->
o_bd
->
be_nsuffix
[
0
];
at
[
0
].
an_name
=
a
.
a_desc
->
ad_cname
;
at
[
0
].
an_desc
=
a
.
a_desc
;
BER_BVZERO
(
&
at
[
1
].
an_name
);
rs
.
sr_entry
=
&
e
;
rs
.
sr_flags
=
REP_ENTRY_MODIFIABLE
;
rs
.
sr_attrs
=
at
;
op
->
o_req_dn
=
e
.
e_name
;
op
->
o_req_ndn
=
e
.
e_nname
;
ldap_pvt_thread_mutex_lock
(
&
si
->
si_cookieState
->
cs_mutex
);
i
=
backend_operational
(
op
,
&
rs
);
if
(
i
==
LDAP_SUCCESS
&&
a
.
a_nvals
)
{
int
num
=
a
.
a_numvals
;
/* check for differences */
if
(
num
!=
si
->
si_cookieState
->
cs_num
)
{
changed
=
1
;
}
else
{
for
(
i
=
0
;
i
<
num
;
i
++
)
{
if
(
ber_bvcmp
(
&
a
.
a_nvals
[
i
],
&
si
->
si_cookieState
->
cs_vals
[
i
]
))
{
changed
=
1
;
break
;
}
}
}
if
(
changed
)
{
ber_bvarray_free
(
si
->
si_cookieState
->
cs_vals
);
ch_free
(
si
->
si_cookieState
->
cs_sids
);
si
->
si_cookieState
->
cs_num
=
num
;
si
->
si_cookieState
->
cs_vals
=
a
.
a_nvals
;
si
->
si_cookieState
->
cs_sids
=
slap_parse_csn_sids
(
a
.
a_nvals
,
num
,
NULL
);
si
->
si_cookieState
->
cs_age
++
;
}
else
{
ber_bvarray_free
(
a
.
a_nvals
);
}
ber_bvarray_free
(
a
.
a_vals
);
}
/* See if the cookieState has changed due to anything outside
* this particular consumer. That includes other consumers in
* the same context, or local changes detected above.
*/
if
(
si
->
si_cookieState
->
cs_num
>
0
&&
si
->
si_cookieAge
!=
si
->
si_cookieState
->
cs_age
)
{
if
(
!
si
->
si_syncCookie
.
numcsns
)
{
ber_bvarray_free
(
si
->
si_syncCookie
.
ctxcsn
);
ber_bvarray_dup_x
(
&
si
->
si_syncCookie
.
ctxcsn
,
si
->
si_cookieState
->
cs_vals
,
NULL
);
changed
=
1
;
}
else
{
for
(
i
=
0
;
!
BER_BVISNULL
(
&
si
->
si_syncCookie
.
ctxcsn
[
i
]
);
i
++
)
{
/* bogus, just dup everything */
if
(
si
->
si_syncCookie
.
sids
[
i
]
==
-
1
)
{
ber_bvarray_free
(
si
->
si_syncCookie
.
ctxcsn
);
ber_bvarray_dup_x
(
&
si
->
si_syncCookie
.
ctxcsn
,
si
->
si_cookieState
->
cs_vals
,
NULL
);
changed
=
1
;
break
;
}
for
(
j
=
0
;
j
<
si
->
si_cookieState
->
cs_num
;
j
++
)
{
if
(
si
->
si_syncCookie
.
sids
[
i
]
!=
si
->
si_cookieState
->
cs_sids
[
j
]
)
continue
;
if
(
bvmatch
(
&
si
->
si_syncCookie
.
ctxcsn
[
i
],
&
si
->
si_cookieState
->
cs_vals
[
j
]
))
break
;
ber_bvreplace
(
&
si
->
si_syncCookie
.
ctxcsn
[
i
],
&
si
->
si_cookieState
->
cs_vals
[
j
]
);
changed
=
1
;
break
;
}
}
}
}
if
(
changed
)
{
si
->
si_cookieAge
=
si
->
si_cookieState
->
cs_age
;
ch_free
(
si
->
si_syncCookie
.
octet_str
.
bv_val
);
slap_compose_sync_cookie
(
NULL
,
&
si
->
si_syncCookie
.
octet_str
,
si
->
si_syncCookie
.
ctxcsn
,
si
->
si_syncCookie
.
rid
,
si
->
si_syncCookie
.
sid
);
}
ldap_pvt_thread_mutex_unlock
(
&
si
->
si_cookieState
->
cs_mutex
);
return
changed
;
}
static
int
do_syncrep1
(
Operation
*
op
,
...
...
@@ -538,104 +644,8 @@ do_syncrep1(
si
->
si_syncCookie
.
ctxcsn
,
si
->
si_syncCookie
.
rid
,
si
->
si_syncCookie
.
sid
);
}
else
{
AttributeName
at
[
2
];
Attribute
a
=
{
0
};
Entry
e
=
{
0
};
SlapReply
rs
=
{
0
};
int
i
,
j
,
changed
=
0
;
/* Look for contextCSN from syncprov overlay. If
* there's no overlay, this will be a no-op. That means
* this is a pure consumer, so local changes will not be
* allowed, and all changes will already be reflected in
* the cookieState.
*/
a
.
a_desc
=
slap_schema
.
si_ad_contextCSN
;
e
.
e_attrs
=
&
a
;
e
.
e_name
=
op
->
o_bd
->
be_suffix
[
0
];
e
.
e_nname
=
op
->
o_bd
->
be_nsuffix
[
0
];
at
[
0
].
an_name
=
a
.
a_desc
->
ad_cname
;
at
[
0
].
an_desc
=
a
.
a_desc
;
BER_BVZERO
(
&
at
[
1
].
an_name
);
rs
.
sr_entry
=
&
e
;
rs
.
sr_flags
=
REP_ENTRY_MODIFIABLE
;
rs
.
sr_attrs
=
at
;
op
->
o_req_dn
=
e
.
e_name
;
op
->
o_req_ndn
=
e
.
e_nname
;
ldap_pvt_thread_mutex_lock
(
&
si
->
si_cookieState
->
cs_mutex
);
rc
=
backend_operational
(
op
,
&
rs
);
if
(
rc
==
LDAP_SUCCESS
&&
a
.
a_nvals
)
{
int
num
=
a
.
a_numvals
;
/* check for differences */
if
(
num
!=
si
->
si_cookieState
->
cs_num
)
{
changed
=
1
;
}
else
{
for
(
i
=
0
;
i
<
num
;
i
++
)
{
if
(
ber_bvcmp
(
&
a
.
a_nvals
[
i
],
&
si
->
si_cookieState
->
cs_vals
[
i
]
))
{
changed
=
1
;
break
;
}
}
}
if
(
changed
)
{
ber_bvarray_free
(
si
->
si_cookieState
->
cs_vals
);
ch_free
(
si
->
si_cookieState
->
cs_sids
);
si
->
si_cookieState
->
cs_num
=
num
;
si
->
si_cookieState
->
cs_vals
=
a
.
a_nvals
;
si
->
si_cookieState
->
cs_sids
=
slap_parse_csn_sids
(
a
.
a_nvals
,
num
,
NULL
);
si
->
si_cookieState
->
cs_age
++
;
}
else
{
ber_bvarray_free
(
a
.
a_nvals
);
}
ber_bvarray_free
(
a
.
a_vals
);
}
/* See if the cookieState has changed due to anything outside
* this particular consumer. That includes other consumers in
* the same context, or local changes detected above.
*/
if
(
si
->
si_cookieState
->
cs_num
>
0
&&
si
->
si_cookieAge
!=
si
->
si_cookieState
->
cs_age
)
{
if
(
!
si
->
si_syncCookie
.
numcsns
)
{
ber_bvarray_free
(
si
->
si_syncCookie
.
ctxcsn
);
ber_bvarray_dup_x
(
&
si
->
si_syncCookie
.
ctxcsn
,
si
->
si_cookieState
->
cs_vals
,
NULL
);
changed
=
1
;
}
else
{
for
(
i
=
0
;
!
BER_BVISNULL
(
&
si
->
si_syncCookie
.
ctxcsn
[
i
]
);
i
++
)
{
/* bogus, just dup everything */
if
(
si
->
si_syncCookie
.
sids
[
i
]
==
-
1
)
{
ber_bvarray_free
(
si
->
si_syncCookie
.
ctxcsn
);
ber_bvarray_dup_x
(
&
si
->
si_syncCookie
.
ctxcsn
,
si
->
si_cookieState
->
cs_vals
,
NULL
);
changed
=
1
;
break
;
}
for
(
j
=
0
;
j
<
si
->
si_cookieState
->
cs_num
;
j
++
)
{
if
(
si
->
si_syncCookie
.
sids
[
i
]
!=
si
->
si_cookieState
->
cs_sids
[
j
]
)
continue
;
if
(
bvmatch
(
&
si
->
si_syncCookie
.
ctxcsn
[
i
],
&
si
->
si_cookieState
->
cs_vals
[
j
]
))
break
;
ber_bvreplace
(
&
si
->
si_syncCookie
.
ctxcsn
[
i
],
&
si
->
si_cookieState
->
cs_vals
[
j
]
);
changed
=
1
;
break
;
}
}
}
}
if
(
changed
)
{
si
->
si_cookieAge
=
si
->
si_cookieState
->
cs_age
;
ch_free
(
si
->
si_syncCookie
.
octet_str
.
bv_val
);
slap_compose_sync_cookie
(
NULL
,
&
si
->
si_syncCookie
.
octet_str
,
si
->
si_syncCookie
.
ctxcsn
,
si
->
si_syncCookie
.
rid
,
si
->
si_syncCookie
.
sid
);
}
ldap_pvt_thread_mutex_unlock
(
&
si
->
si_cookieState
->
cs_mutex
);
/* Look for contextCSN from syncprov overlay. */
check_syncprov
(
op
,
si
);
}
si
->
si_refreshDone
=
0
;
...
...
@@ -915,6 +925,10 @@ do_syncrep2(
}
ber_scanf
(
ber
,
/*"{"*/
"}"
);
}
if
(
SLAP_MULTIMASTER
(
op
->
o_bd
)
&&
check_syncprov
(
op
,
si
))
{
slap_sync_cookie_free
(
&
syncCookie_req
,
0
);
slap_dup_sync_cookie
(
&
syncCookie_req
,
&
si
->
si_syncCookie
);
}
if
(
!
syncCookie
.
ctxcsn
)
{
match
=
1
;
}
else
if
(
!
syncCookie_req
.
ctxcsn
)
{
...
...
@@ -932,7 +946,8 @@ do_syncrep2(
* 2) on err policy : stop service, stop sync, retry
*/
if
(
refreshDeletes
==
0
&&
match
<
0
&&
err
==
LDAP_SUCCESS
)
err
==
LDAP_SUCCESS
&&
syncCookie_req
.
numcsns
==
syncCookie
.
numcsns
)
{
syncrepl_del_nonpresent
(
op
,
si
,
NULL
,
&
syncCookie
.
ctxcsn
[
m
]
);
...
...
@@ -1067,6 +1082,10 @@ do_syncrep2(
continue
;
}
if
(
SLAP_MULTIMASTER
(
op
->
o_bd
)
&&
check_syncprov
(
op
,
si
))
{
slap_sync_cookie_free
(
&
syncCookie_req
,
0
);
slap_dup_sync_cookie
(
&
syncCookie_req
,
&
si
->
si_syncCookie
);
}
if
(
!
syncCookie
.
ctxcsn
)
{
match
=
1
;
}
else
if
(
!
syncCookie_req
.
ctxcsn
)
{
...
...
@@ -1077,7 +1096,8 @@ do_syncrep2(
}
if
(
match
<
0
)
{
if
(
si
->
si_refreshPresent
==
1
)
{
if
(
si
->
si_refreshPresent
==
1
&&
syncCookie_req
.
numcsns
==
syncCookie
.
numcsns
)
{
syncrepl_del_nonpresent
(
op
,
si
,
NULL
,
&
syncCookie
.
ctxcsn
[
m
]
);
}
...
...
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