Hello,
I'm hoping this is the right place for questions like this. I'm writing a
module that relies on apr_dbm to write entries to a Berkeley DB file (in
apr_dbm, DB) on local disk. In my experience so far, it doesn't seem to work
within an Apache module. To be sure the apr_dbm code worked at all, I wrote
a standalone APR utility that would add and list the contents of a bdb file,
and that worked without problems.
As I understand it, BDBs have a fairly sophisticated locking scheme, so I
wasn't sure if I needed a mutex on each dbm store, or if that was handled at
a lower level.
My questions are:
* Can I have multiple writers? i.e. multiple apr_dbm_open_ex() with
APR_DBM_RWCREATE
* Do I need to set up process/thread mutexes for writes?
Here's a snippet from my test module:
timestr = apr_itoa(r->pool, apr_time_sec(apr_time_now()));
key.dptr = timestr;
key.dsize = strlen(timestr);
value.dptr = "bdbtest";
value.dsize = 7;
rv = apr_dbm_open_ex(&dbm, "DB", "/tmp/bdbtest.db", APR_DBM_RWCREATE,
APR_OS_DEFAULT, r->pool);
if (rv != APR_SUCCESS) {
ap_rputs("Could not open SDB for writing", r);
return OK;
}
rv = apr_dbm_store(dbm, key, value);
if (rv != APR_SUCCESS) {
ap_rputs("Couldn't store key in SDB", r);
return OK;
}
Upon futher inspection (both within a module and the standalone APR util), I
don't see that the key/value pair has been added. apr_dbm_store() is
returning APR_SUCCESS.
Any ideas about what I could be doing wrong?
Thanks