Re: (ITS#8270) win32: fix conversion error
by leo@yuriev.ru
--001a11c23788b1353405228fbfbd
Content-Type: text/plain; charset=UTF-8
2015-10-20 23:09 GMT+03:00 <hyc(a)symas.com>:
> nacho.resa(a)gmail.com wrote:
> > --047d7bb03a5ac118d20522842ead
> > Content-Type: text/plain; charset=UTF-8
> >
> > So I took another closer look at this issue and I went for this possible
> > solution:
> >
> https://github.com/nice-software/lmdb/commit/03987789735141dc68ae8b2d0e5a...
>
> That looks OK.
>
> > Basically it errors out because MSVC needs stdcall on that method.
>
> You realize of course, that this change actually has no effect on the code
> here? stdcall uses Pascal argument order instead of C order but it's moot
> since the function only has 1 argument.
>
>
No, there is another important difference:
cdecl = the caller is responsible to clean stack from args (e.g. addl esp,
N);
stdcall = the callee is responsible to clean stack from args (e.g. retn N);
--001a11c23788b1353405228fbfbd
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">2015=
-10-20 23:09 GMT+03:00 <span dir=3D"ltr"><<a href=3D"mailto:hyc@symas.c=
om" target=3D"_blank">hyc(a)symas.com</a>></span>:<br><blockquote class=3D=
"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;borde=
r-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><a =
href=3D"mailto:nacho.resa@gmail.com">nacho.resa(a)gmail.com</a> wrote:<br>
> --047d7bb03a5ac118d20522842ead<br>
> Content-Type: text/plain; charset=3DUTF-8<br>
><br>
> So I took another closer look at this issue and I went for this possib=
le<br>
> solution:<br>
> <a href=3D"https://github.com/nice-software/lmdb/commit/03987789735141=
dc68ae8b2d0e5ad52d82cc80d0" rel=3D"noreferrer" target=3D"_blank">https://gi=
thub.com/nice-software/lmdb/commit/03987789735141dc68ae8b2d0e5ad52d82cc80d0=
</a><br>
<br>
That looks OK.<br>
<br>
> Basically it errors out because MSVC needs stdcall on that method.<br>
<br>
You realize of course, that this change actually has no effect on the code<=
br>
here? stdcall uses Pascal argument order instead of C order but it's mo=
ot<br>
since the function only has 1 argument.<br>
<br></blockquote><div><br><div>No, there is another important difference:</=
div><div>cdecl =3D the caller is responsible to clean stack from args (e.g.=
addl esp, N);</div>stdcall =3D the callee is responsible to clean stack fr=
om args (e.g. retn N);=C2=A0</div></div></div></div>
--001a11c23788b1353405228fbfbd--
7 years, 7 months
Re: (ITS#8270) win32: fix conversion error
by nacho.resa@gmail.com
--f46d043895179821ec05228f3c91
Content-Type: text/plain; charset=UTF-8
On Tue, Oct 20, 2015 at 10:09 PM, Howard Chu <hyc(a)symas.com> wrote:
> nacho.resa(a)gmail.com wrote:
>
>> --047d7bb03a5ac118d20522842ead
>> Content-Type: text/plain; charset=UTF-8
>>
>> So I took another closer look at this issue and I went for this possible
>> solution:
>>
>> https://github.com/nice-software/lmdb/commit/03987789735141dc68ae8b2d0e5a...
>>
>
> That looks OK.
>
> Basically it errors out because MSVC needs stdcall on that method.
>>
>
> You realize of course, that this change actually has no effect on the code
> here? stdcall uses Pascal argument order instead of C order but it's moot
> since the function only has 1 argument.
>
yeah... but if this fixes the error I am fine with it, after all it end ups
being just a define
>
>
>> Cheers.
>>
>> On Mon, Oct 19, 2015 at 2:55 PM, Ignacio Casal Quinteiro <
>> nacho.resa(a)gmail.com> wrote:
>>
>> Sorry! I did indeed meant to change just the windows part, for some reason
>>> I thought it was already ifdeffed that part.
>>>
>>>
>>> https://github.com/nice-software/lmdb/commit/42577fe173923c1166f8382a5352...
>>>
>>> This is the right patch.
>>>
>>> On Mon, Oct 19, 2015 at 1:43 PM, Hallvard Breien Furuseth <
>>> h.b.furuseth(a)usit.uio.no> wrote:
>>>
>>> On 19. okt. 2015 08:57, nacho.resa(a)gmail.com wrote:
>>>>
>>>> I do not understand, I tested also with mingw64 (...)
>>>>>
>>>>>
>>>> There's no LPTHREAD_START_ROUTINE type on non-Windows machines.
>>>> You could replace 'start' with '(LPTHREAD_START_ROUTINE)(start)'
>>>> in the _WIN32 variant of '#define THREAD_CREATE...'.
>>>>
>>>> However, it's still wrong to call a function via another prototype.
>>>> Maybe that'd fall on 32-bit Windows or something, I don't know
>>>> how LPTHREAD_START_ROUTINE is defined. The safe way would be to
>>>> give mdb_env_copythr() a prototype which does not need a cast.
>>>> There is some code for that already. Maybe it can be improved.
>>>>
>>>> --
>>>> Hallvard
>>>>
>>>>
>>>
>>>
>>> --
>>> Ignacio Casal Quinteiro
>>>
>>>
>>
>>
>>
>
> --
> -- Howard Chu
> CTO, Symas Corp. http://www.symas.com
> Director, Highland Sun http://highlandsun.com/hyc/
> Chief Architect, OpenLDAP http://www.openldap.org/project/
>
--
Ignacio Casal Quinteiro
--f46d043895179821ec05228f3c91
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On Tue, Oct 20, 2015 at 10:09 PM, Howard Chu <span dir=3D"ltr"><<a h=
ref=3D"mailto:hyc@symas.com" target=3D"_blank">hyc(a)symas.com</a>></span>=
wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;bor=
der-left:1px #ccc solid;padding-left:1ex"><a href=3D"mailto:nacho.resa@gmai=
l.com" target=3D"_blank">nacho.resa(a)gmail.com</a> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">
--047d7bb03a5ac118d20522842ead<br>
Content-Type: text/plain; charset=3DUTF-8<span class=3D""><br>
<br>
So I took another closer look at this issue and I went for this possible<br=
>
solution:<br>
<a href=3D"https://github.com/nice-software/lmdb/commit/03987789735141dc68a=
e8b2d0e5ad52d82cc80d0" rel=3D"noreferrer" target=3D"_blank">https://github.=
com/nice-software/lmdb/commit/03987789735141dc68ae8b2d0e5ad52d82cc80d0</a><=
br>
</span></blockquote>
<br>
That looks OK.<span class=3D""><br>
<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">
Basically it errors out because MSVC needs stdcall on that method.<br>
</blockquote>
<br></span>
You realize of course, that this change actually has no effect on the code =
here? stdcall uses Pascal argument order instead of C order but it's mo=
ot since the function only has 1 argument.<span class=3D"im HOEnZb"><br></s=
pan></blockquote><div><br></div><div>yeah... but if this fixes the error I =
am fine with it, after all it end ups being just a define<br></div><div>=C2=
=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;borde=
r-left:1px #ccc solid;padding-left:1ex"><span class=3D"im HOEnZb">
<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">
<br>
Cheers.<br>
<br>
On Mon, Oct 19, 2015 at 2:55 PM, Ignacio Casal Quinteiro <<br>
<a href=3D"mailto:nacho.resa@gmail.com" target=3D"_blank">nacho.resa(a)gmail.=
com</a>> wrote:<br>
<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">
Sorry! I did indeed meant to change just the windows part, for some reason<=
br>
I thought it was already ifdeffed that part.<br>
<br>
<a href=3D"https://github.com/nice-software/lmdb/commit/42577fe173923c1166f=
8382a53523a31479f9d43" rel=3D"noreferrer" target=3D"_blank">https://github.=
com/nice-software/lmdb/commit/42577fe173923c1166f8382a53523a31479f9d43</a><=
br>
<br>
This is the right patch.<br>
<br>
On Mon, Oct 19, 2015 at 1:43 PM, Hallvard Breien Furuseth <<br>
<a href=3D"mailto:h.b.furuseth@usit.uio.no" target=3D"_blank">h.b.furuseth@=
usit.uio.no</a>> wrote:<br>
<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">
On 19. okt. 2015 08:57, <a href=3D"mailto:nacho.resa@gmail.com" target=3D"_=
blank">nacho.resa(a)gmail.com</a> wrote:<br>
<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">
I do not understand, I tested also with mingw64 (...)<br>
<br>
</blockquote>
<br>
There's no LPTHREAD_START_ROUTINE type on non-Windows machines.<br>
You could replace 'start' with '(LPTHREAD_START_ROUTINE)(start)=
'<br>
in the _WIN32 variant of '#define THREAD_CREATE...'.<br>
<br>
However, it's still wrong to call a function via another prototype.<br>
Maybe that'd fall on 32-bit Windows or something, I don't know<br>
how LPTHREAD_START_ROUTINE is defined.=C2=A0 The safe way would be to<br>
give mdb_env_copythr() a prototype which does not need a cast.<br>
There is some code for that already. Maybe it can be improved.<br>
<br>
--<br>
Hallvard<br>
<br>
</blockquote>
<br>
<br>
<br>
--<br>
Ignacio Casal Quinteiro<br>
<br>
</blockquote>
<br>
<br>
<br>
</blockquote>
<br>
<br>
-- <br></span><div class=3D"HOEnZb"><div class=3D"h5">
=C2=A0 -- Howard Chu<br>
=C2=A0 CTO, Symas Corp.=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0<a href=3D"=
http://www.symas.com" rel=3D"noreferrer" target=3D"_blank">http://www.symas=
.com</a><br>
=C2=A0 Director, Highland Sun=C2=A0 =C2=A0 =C2=A0<a href=3D"http://highland=
sun.com/hyc/" rel=3D"noreferrer" target=3D"_blank">http://highlandsun.com/h=
yc/</a><br>
=C2=A0 Chief Architect, OpenLDAP=C2=A0 <a href=3D"http://www.openldap.org/p=
roject/" rel=3D"noreferrer" target=3D"_blank">http://www.openldap.org/proje=
ct/</a><br>
</div></div></blockquote></div><br><br clear=3D"all"><br>-- <br><div class=
=3D"gmail_signature">Ignacio Casal Quinteiro</div>
</div></div>
--f46d043895179821ec05228f3c91--
7 years, 7 months
Re: (ITS#8270) win32: fix conversion error
by hyc@symas.com
nacho.resa(a)gmail.com wrote:
> --047d7bb03a5ac118d20522842ead
> Content-Type: text/plain; charset=UTF-8
>
> So I took another closer look at this issue and I went for this possible
> solution:
> https://github.com/nice-software/lmdb/commit/03987789735141dc68ae8b2d0e5a...
That looks OK.
> Basically it errors out because MSVC needs stdcall on that method.
You realize of course, that this change actually has no effect on the code
here? stdcall uses Pascal argument order instead of C order but it's moot
since the function only has 1 argument.
>
> Cheers.
>
> On Mon, Oct 19, 2015 at 2:55 PM, Ignacio Casal Quinteiro <
> nacho.resa(a)gmail.com> wrote:
>
>> Sorry! I did indeed meant to change just the windows part, for some reason
>> I thought it was already ifdeffed that part.
>>
>> https://github.com/nice-software/lmdb/commit/42577fe173923c1166f8382a5352...
>>
>> This is the right patch.
>>
>> On Mon, Oct 19, 2015 at 1:43 PM, Hallvard Breien Furuseth <
>> h.b.furuseth(a)usit.uio.no> wrote:
>>
>>> On 19. okt. 2015 08:57, nacho.resa(a)gmail.com wrote:
>>>
>>>> I do not understand, I tested also with mingw64 (...)
>>>>
>>>
>>> There's no LPTHREAD_START_ROUTINE type on non-Windows machines.
>>> You could replace 'start' with '(LPTHREAD_START_ROUTINE)(start)'
>>> in the _WIN32 variant of '#define THREAD_CREATE...'.
>>>
>>> However, it's still wrong to call a function via another prototype.
>>> Maybe that'd fall on 32-bit Windows or something, I don't know
>>> how LPTHREAD_START_ROUTINE is defined. The safe way would be to
>>> give mdb_env_copythr() a prototype which does not need a cast.
>>> There is some code for that already. Maybe it can be improved.
>>>
>>> --
>>> Hallvard
>>>
>>
>>
>>
>> --
>> Ignacio Casal Quinteiro
>>
>
>
>
--
-- Howard Chu
CTO, Symas Corp. http://www.symas.com
Director, Highland Sun http://highlandsun.com/hyc/
Chief Architect, OpenLDAP http://www.openldap.org/project/
7 years, 7 months
Re: (ITS#8278) slapd fails to start when built with --enable-slp on freebsd
by h.b.furuseth@usit.uio.no
On 20. okt. 2015 00:28, quanah(a)openldap.org wrote:
> slapd will not start, exits with "slap_schema_init: Error registering matching
> rule ( 2.5.13.28 NAME 'generalizedTimeOrderingMatch' SYNTAX
> 1.3.6.1.4.1.1466.115.121.1.24 )"
Reported to OpenSLP: <http://sourceforge.net/p/openslp/bugs/149/>.
libslp 2.0.0 redefines strncasecmp() unless HAVE_STRNCASECMP,
which it does not #define. Building OpenSLP (not OpenLDAP) with
'./configure CPPFLAGS=-DHAVE_STRNCASECMP' fixes it.
--
Hallvard
7 years, 7 months
Re: (ITS#8278) slapd fails to start when built with --enable-slp on freebsd
by ryan@nardis.ca
On Mon, Oct 19, 2015 at 10:28:40PM +0000, quanah(a)openldap.org wrote:
>OS: FreeBSD 10.1
FTR, this is not FreeBSD specific. I reproduced it easily on Linux
(Debian unstable). Only happens when using OpenSLP 2.0.0, not with
1.2.1. Have not figured out whether it's an OpenSLP bug or a change we
need to adapt to.
7 years, 7 months
Re: (ITS#8270) win32: fix conversion error
by nacho.resa@gmail.com
--047d7bb03a5ac118d20522842ead
Content-Type: text/plain; charset=UTF-8
So I took another closer look at this issue and I went for this possible
solution:
https://github.com/nice-software/lmdb/commit/03987789735141dc68ae8b2d0e5a...
Basically it errors out because MSVC needs stdcall on that method.
Cheers.
On Mon, Oct 19, 2015 at 2:55 PM, Ignacio Casal Quinteiro <
nacho.resa(a)gmail.com> wrote:
> Sorry! I did indeed meant to change just the windows part, for some reason
> I thought it was already ifdeffed that part.
>
> https://github.com/nice-software/lmdb/commit/42577fe173923c1166f8382a5352...
>
> This is the right patch.
>
> On Mon, Oct 19, 2015 at 1:43 PM, Hallvard Breien Furuseth <
> h.b.furuseth(a)usit.uio.no> wrote:
>
>> On 19. okt. 2015 08:57, nacho.resa(a)gmail.com wrote:
>>
>>> I do not understand, I tested also with mingw64 (...)
>>>
>>
>> There's no LPTHREAD_START_ROUTINE type on non-Windows machines.
>> You could replace 'start' with '(LPTHREAD_START_ROUTINE)(start)'
>> in the _WIN32 variant of '#define THREAD_CREATE...'.
>>
>> However, it's still wrong to call a function via another prototype.
>> Maybe that'd fall on 32-bit Windows or something, I don't know
>> how LPTHREAD_START_ROUTINE is defined. The safe way would be to
>> give mdb_env_copythr() a prototype which does not need a cast.
>> There is some code for that already. Maybe it can be improved.
>>
>> --
>> Hallvard
>>
>
>
>
> --
> Ignacio Casal Quinteiro
>
--
Ignacio Casal Quinteiro
--047d7bb03a5ac118d20522842ead
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div><div>So I took another closer look at this issue and =
I went for this possible solution:<br><a href=3D"https://github.com/nice-so=
ftware/lmdb/commit/03987789735141dc68ae8b2d0e5ad52d82cc80d0">https://github=
.com/nice-software/lmdb/commit/03987789735141dc68ae8b2d0e5ad52d82cc80d0</a>=
<br><br></div>Basically it errors out because MSVC needs stdcall on that me=
thod.<br><br></div>Cheers.<br></div><div class=3D"gmail_extra"><br><div cla=
ss=3D"gmail_quote">On Mon, Oct 19, 2015 at 2:55 PM, Ignacio Casal Quinteiro=
<span dir=3D"ltr"><<a href=3D"mailto:nacho.resa@gmail.com" target=3D"_b=
lank">nacho.resa(a)gmail.com</a>></span> wrote:<br><blockquote class=3D"gm=
ail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-le=
ft:1ex"><div dir=3D"ltr"><div>Sorry! I did indeed meant to change just the =
windows part, for some reason I thought it was already ifdeffed that part.<=
br><a href=3D"https://github.com/nice-software/lmdb/commit/42577fe173923c11=
66f8382a53523a31479f9d43" target=3D"_blank">https://github.com/nice-softwar=
e/lmdb/commit/42577fe173923c1166f8382a53523a31479f9d43</a><br><br></div>Thi=
s is the right patch.<br></div><div class=3D"gmail_extra"><div><div class=
=3D"h5"><br><div class=3D"gmail_quote">On Mon, Oct 19, 2015 at 1:43 PM, Hal=
lvard Breien Furuseth <span dir=3D"ltr"><<a href=3D"mailto:h.b.furuseth@=
usit.uio.no" target=3D"_blank">h.b.furuseth(a)usit.uio.no</a>></span> wrot=
e:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-l=
eft:1px #ccc solid;padding-left:1ex">On 19. okt. 2015 08:57, <a href=3D"mai=
lto:nacho.resa@gmail.com" target=3D"_blank">nacho.resa(a)gmail.com</a> wrote:=
<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">
I do not understand, I tested also with mingw64 (...)<br>
</blockquote>
<br>
There's no LPTHREAD_START_ROUTINE type on non-Windows machines.<br>
You could replace 'start' with '(LPTHREAD_START_ROUTINE)(start)=
'<br>
in the _WIN32 variant of '#define THREAD_CREATE...'.<br>
<br>
However, it's still wrong to call a function via another prototype.<br>
Maybe that'd fall on 32-bit Windows or something, I don't know<br>
how LPTHREAD_START_ROUTINE is defined.=C2=A0 The safe way would be to<br>
give mdb_env_copythr() a prototype which does not need a cast.<br>
There is some code for that already. Maybe it can be improved.<span><font c=
olor=3D"#888888"><br>
<br>
-- <br>
Hallvard<br>
</font></span></blockquote></div><br><br clear=3D"all"><br></div></div><spa=
n class=3D"HOEnZb"><font color=3D"#888888">-- <br><div>Ignacio Casal Quinte=
iro</div>
</font></span></div>
</blockquote></div><br><br clear=3D"all"><br>-- <br><div class=3D"gmail_sig=
nature">Ignacio Casal Quinteiro</div>
</div>
--047d7bb03a5ac118d20522842ead--
7 years, 7 months
(ITS#8277) test049 crashes
by hyc@openldap.org
Full_Name: Howard Chu
Version: 2.4
OS: Win32
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (78.155.231.14)
Submitted by: hyc
After "replacing syncrepl on provider" the consumer crashes. Stack trace shows a
do_syncrepl thread trying to lock a syncinfo mutex that is no longer valid,
i.e., the syncinfo has been freed.
This happens when the consumer receives the syncrepl config change - it deletes
the existing config (thus freeing it) and creates a new one. Something funny is
going on here since the config change itself is being processed in the consumer,
and no other thread should have been started for this syncrepl instance.
7 years, 7 months
(ITS#8276) [PATCH 2/2] Add an application context pointer into user-defined key compare and dupsort functions
by pmedvedev@gmail.com
Full_Name: Pavel Medvedev
Version:
OS:
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (217.25.225.40)
This allows to use application context in user-defined compare functions.
---
libraries/liblmdb/lmdb.h | 14 ++++++++++----
libraries/liblmdb/mdb.c | 40 ++++++++++++++++"B2B+++++-----------------
2 files changed, 33 insertions(+), 21 deletions(-)
diff --git a/libraries/liblmdb/lmdb.h b/libraries/liblmdb/lmdb.h
index 933a862..debdf43 100644
--- a/libraries/liblmdb/lmdb.h
+++ b/libraries/liblmdb/lmdb.h
@@ -251,8 +251,12 @@ typedef struct MDB_val {
void *mv_data; /**< address of the data item */
} MDB_val;
-/** @brief A callback function used to compare two keys in a database */
-typedef int (MDB_cmp_func)(const MDB_val *a, const MDB_val *b);
+/** @brief A callback function used to compare two keys in a database
+* @param[in] a The first value to compare.
+* @param[in] b The second value to compare.
+* @param[in] cmpctx An application-provided context, set by #mdb_set_compare()
or #mdb_set_dupsort().
+*/
+typedef int (MDB_cmp_func)(const MDB_val *a, const MDB_val *b, void *cmpctx);
/** @brief A callback function used to relocate a position-dependent data item
* in a fixed-address database.
@@ -1193,13 +1197,14 @@ int mdb_drop(MDB_txn *txn, MDB_dbi dbi, int del);
* @param[in] txn A transaction handle returned by #mdb_txn_begin()
* @param[in] dbi A database handle returned by #mdb_dbi_open()
* @param[in] cmp A #MDB_cmp_func function
+ * @param[in] cmpctx An arbitrary pointer for whatever the application needs.
* @return A non-zero error value on failure and 0 on success. Some possible
* errors are:
* <ul>
* <li>EINVAL - an invalid parameter was specified.
* </ul>
*/
-int mdb_set_compare(MDB_txn *txn, MDB_dbi dbi, MDB_cmp_func *cmp);
+int mdb_set_compare(MDB_txn *txn, MDB_dbi dbi, MDB_cmp_func *cmp, void
*cmpctx);
/** @brief Set a custom data comparison function for a #MDB_DUPSORT database.
*
@@ -1216,13 +1221,14 @@ int mdb_set_compare(MDB_txn *txn, MDB_dbi dbi,
MDB_cmp_func *cmp);
* @param[in] txn A transaction handle returned by #mdb_txn_begin()
* @param[in] dbi A database handle returned by #mdb_dbi_open()
* @param[in] cmp A #MDB_cmp_func function
+ * @param[in] cmpctx An arbitrary pointer forhahatever the application needs.
* @return A non-zero error value on failure and 0 on success. Some possible
* errors are:
* <ul>
* <li>EINVAL - an invalid parameter was specified.
* </ul>
*/
-int mdb_set_dupsort(MDB_txn *txn, MDB_dbi dbi, MDB_cmp_func *cmp);
+int mdb_set_dupsort(MDB_txn *txn, MDB_dbi dbi, MDB_cmp_func *cmp, void
*cmpctx);
/** @brief Set a relocation function for a #MDB_FIXEDMAP database.
*
diff --git a/libraries/liblmdb/mdb.c b/libraries/liblmdb-bdb.c
index a2763f8..f816a44 100644
--- a/libraries/liblmdb/mdb.c
+++ b/libraries/liblmdb/mdb.c
@@ -1057,7 +1057,9 @@ typedef union MDB_metabuf {
typedef struct MDB_dbx {
MDB_val md_name; /**< name of the database */
MDB_cmp_func9*9*md_cmp; /**< function for comparing keys */
+ void *md_cmpctx; /**< user-provided context for md_cmp*/
MDB_cmp_func *md_dcmp; /**< function for comparing data items */
+ void *md_dcmpctx; /**< user-provided context for md_dcmp */A A MDB_rel_func
*md_rel; /**< user relocate function */
void *md_relctx; /**< user-provided context for md_rel */
} MDB_dbx;
@@ -1709,7 +1711,7 @@ static void mdb_audit(MDB_txn *txn)
int
mdb_cmp(MDB_txn *txn, MDB_dbi dbi, const MDB_val *a, const MDB_val *b)
{
- return txn->mt_dbxs[dbi].md_cmp(a, b);
+ return txn->mt_dbxs[dbi].md_cmp(a, b, txn->mt_dbxs[dbi].md_cmpctx);
}
int
@@ -1720,7 +1722,7 @@ mdb_dcmp(MDB_txn *txn, MDB_dbi dbi, const MDB_val *a,
const MDB_val *b)
if (dcmp == mdb_cmp_int && a->mv_size == sizeof(size_t))
dcmp = mdb_cmp_clong;
#endif
- return dcmp(a, b);
+ return dcmp(a, b, txn->mt_dbxs[dbi].md_dcmpctx);
}
/** Allocate memory for a page.
@@ -5003,7 +5005,7 @@ mdb_env_close(MDB_env *env)
/** Compare two items pointing at aligned size_t's */
static int
-mdb_cmp_long(const MDB_val *a, const MDB_val *b)
+mdb_cmp_long(const MDB_val *a, const MDB_val *b, void *cmpctx)
{
return (*(size_t *)a->mv_data < *(size_t *)b->mv_data) ? -1 :
*(size_t *)a->mv_data > *(size_t *)b->mv_data;
@@ -5015,7 +5017,7 @@ mdb_cmp_long(const MDB_val *a, const MDB_val *b)
* but #mdb_cmp_clong() is called instead if the data type is size_t.
*/
static int
-mdb_cmp_int(const MDB_val *a, const MDB_val *b)
+mdb_cmp_int(const MDB_val *a, const MDB_v *b%b, void *cmpctx)
{
return (*(unsigned int *)a->mv_data < *(unsigned int *)b->mv_data) ? -1 :
*(unsigned int *)a->mv_data > *(unsigned int *)b->mv_data;
@@ -5025,7 +5027,7 @@ mdb_cmp_int(const MDB_val *a, const MDB_val *b)
* Nodes and keys are guaranteed to be 2-byte aligned.
*/
static int
-mdb_cmp_cint(const MDB_val *a, const MDB_val *b)
+mdb_cmp_cint(const MDB_val *a, const MDB_val *b, void *cmpctx)
{
#if BYTE_ORDER == LITTLE_ENDIAN
unsigned short *u, *c;
@@ -5053,7 +5055,7 @@ mdb_cmp_cint(const MDB_val *a, const MDB_val *b)
/** Compare two items lexically */
static int
-mdb_cmp_memn(const MDB_val *a, const MDB_val *b)
+mdb_cmp_memn(const MDB_val *a, const MDB_val *b, void *cmpctx)
{
int diff;
ssize_t len_diff;
@@ -5072,7 +5074,7 @@ mdb_cmp_memn(const MDB_val *a, const MDB_val *b)
/** Compare two items in reverse byte order */
static int
-mdb_cmp_memnr(const MDB_val *a, const MDB_val *b)
+mdb_cmp_memnr(const MDB_val *a, const MDB_val *b, void *cmpctx)
{
const unsigned char *p1, *p2, *p1_lim;
ssize_t len_diff;
@@ -5113,6 +5115,7 @@ mdb_node_search(MDB_cursor *mc, MDB_val *key, int
*exactp)
MDB_node *node = NULL;
MDB_val nodekey;
MDB_cmp_func *cmp;
+ void *cmpctx;
DKBUF;
nkeys = NUMKEYS(mp);
@@ -5124,6 +5127,7 @@ mdb_node_search(MDB_cursor *mc, MDB_val *key, int
*exactp)
low = IS_LEAF(mp) ? 0 : 1;
high = nkeys - 1;
cmp = mc->mc_dbx->md_cmp;
+ cmpctx = mc->mc_dbx->md_cmpctx;
/* Branch pages have no data% so o if using integer keys,
* alignment is guaranteed. Use faster mdb_cmp_int.
@@ -5141,7 +5145,7 @@ mdb_node_search(MDB_cursor *mc, MDB_val *key, int
*exactp)
while (low <= high) {
i = (low + high) >> 1;
nodey.m.mv_data = LEAF2KEY(mp, i, nodekey.mv_size);
- rc = cmp(key, &nodekey);
+ rc = cmp(key, &nodekey, cmpctx);
DPRINTF(("found leaf index %u [%s], rc = %i",
i, DKEY(&nodekey), rc));
if (rc == 0)
@@ -5159,7 +5163,7 @@ mdb_node_search(MDB_cursor *mc, MDB_val *key, int
*exactp)
nodekey.mv_size = NODEKSZ(node);
nodekey.mv_data = NODEKEY(node);
- rc = cmp(key, &nodekey);
+ rc = cmp(key, &nodekey, cmpctx);
#if MDB_DEBUG
if (IS_LEAF(mp))
DPRINTF(("found leaf index %u [%s], rc = %i",
@@ -5855,7 +5859,7 @@ mdb_cursor_set(MDB_cursor *mc, MDB_val *key, MDB_val
*data,
leaf = NODEPTR(mp, 0);
MDB_GET_KEY2(leaf, nodekey);
}
- rc = mc->mc_dbx->md_cmp(key, &nodekey);
+ rc = mc->mc_dbx->md_cmp(key, &nodekey, mc->mc_dbx->md_cmpctx);
if (rc == 0) {
/* Probably happens rarely, but first node on the page
* was the one we wanted.
@@ -5876,7 +5880,7 @@ mdb_cursor_set(MDB_cursor *mc, MDB_val *key, MDB_val
*data,
leaf = NODEPTR(%2, nkeys-1);
MDB_GET_KEY2(leaf, nodekey);
}
- rc = mc->mc_dbx->md_cmp(key, &nodekey);
+ rc = mc->mc_dbx->md_cmp(key, &nodekey, mc->mc_dbx->md_cmpctx);
if (rc == 0) {
/* last node was the one we wanted */
mc->mc_ki[mc->mc_top] D D nkeys-1;
@@ -5894,7 +5898,7 @@ mdb_cursor_set(MDB_cursor *mc, MDB_val *key, MDB_val
*data,
leaf = NODEPTR(mp, mc->mc_ki[mc->mc_top]);
MDB_GET_KEY2(leaf, nodekey);
}
- rc = mc->mc_dbx->md_cmp(key, &nodekey);A%A+ rc =
mc->mc_dbx->md_cmp(key, &nodekey, mc->mc_dbx->md_cmpctx);
if (rc == 0) {
/* current node was the one we wanted */
if (exactp)
@@ -5996,7 +6000,7 @@ set1:
if (dcmp == mdb_cmp_int && olddata.mv_size == sizeof(size_t))
dcmp = mdb_cmp_clong;
#endif
- rc = dcmp(data, &olddata);
+ rc = dcmp(data, &olddata, mc->mc_dbx->md_dcmpctx);
if (rc) {
if (op == MDB_GET_BOTH || rc > 0)
return MDB_NOTFOUND;
@@ -6387,7 +6391,7 @@ mdb_cursor_put(MDB_cursor *mc, MDB_val *key, MDB_val
*data,
MDB_val k2;
rc = mdb_cursor_last(mc, &k2, &d2);
if (rc == 0) {
- rc = mc->mc_dbx->md_cmp(key, &k2);
+ rc = mc->mc_dbx->md_cmp(key, &k2, mc->mc_dbx->md_cmpctx);
if (rc > 0) {
rc = MDB_NOTFOUND;
mc->mc_k5B5Bmc->mc_top]++;
@@ -6520,7 +6524,7 @@ more:
dcmp = mdb_cmp_clong;
#endif
/* does data match? */
- if (!dcmp(data, &olddata)) {
+ if (!dcmp(data, &olddata, mc->mc_dbx->md_dcmpctx)) {
if (flags &DMDB_NODUPDATA)
return MDB_KEYEXIST;
/* overwrite it */
@@ -9690,21 +9694,23 @@ leave:
return rc;
}
-int mdb_set_compare(MDB_txn *txn, MDB_dbi dbi, MDB_cmp_func *cmp)
+int mdb_set_compare(MDB_txn *txn, MDB_dbi dbi, MDB_cmp_func *cmp, void
*cmpctx)
{
if (!TXN_DBI_EXIST(txn, dbi, DB_USRVALID))
return EINVAL;
txn->mt_dbxs[dbi].md_cmp = cmp;
+ txn->mt_dbxs[dbi].md_cmpctx = cmpctx;
return MDB_SUCCESS;
}
-int mdb_set_dupsort(MDB_txn *txn, MDB_dbi dbi, MDB_cmp_func *cmp)
+int mdb_set_dupsort(MDB_txn *txn, MDB_dbi dbi, MDB_cmp_func *cmp, void
*cmpctx)
{
if (!TXN_DBI_EXIST(txn, dbi, DB_USRVALID))
return EINVAL;
txn->mt_dbxs[dbi].md_dcmp = cmp;
+ txn->mt_dbxs[dbi].md_dcmpctx = cmpctx;
return MDB_SUCCESS;
}
7 years, 7 months