#include "includes.h"
#include "system/filesys.h"
-#include "dbwrap.h"
+#include "dbwrap/dbwrap.h"
#include "dbwrap_watch.h"
#include "dbwrap_open.h"
#include "msg_channel.h"
static struct db_context *watchers_db;
if (watchers_db == NULL) {
- watchers_db = db_open(NULL, lock_path("dbwrap_watchers.tdb"),
- 0, TDB_CLEAR_IF_FIRST, O_RDWR|O_CREAT,
- 0600, DBWRAP_LOCK_ORDER_3);
+ watchers_db = db_open(
+ NULL, lock_path("dbwrap_watchers.tdb"), 0,
+ TDB_CLEAR_IF_FIRST | TDB_INCOMPATIBLE_HASH,
+ O_RDWR|O_CREAT, 0600, DBWRAP_LOCK_ORDER_3);
}
return watchers_db;
}
ids = (struct server_id *)value.dptr;
num_ids = value.dsize / sizeof(struct server_id);
- ids = talloc_realloc(talloc_tos(), ids, struct server_id,
- num_ids + 1);
+ ids = talloc_array(talloc_tos(), struct server_id,
+ num_ids + 1);
if (ids == NULL) {
status = NT_STATUS_NO_MEMORY;
goto fail;
}
+ memcpy(ids, value.dptr, value.dsize);
ids[num_ids] = id;
num_ids += 1;
num_ids = value.dsize / sizeof(struct server_id);
for (i=0; i<num_ids; i++) {
- if (procid_equal(&id, &ids[i])) {
+ if (serverid_equal(&id, &ids[i])) {
ids[i] = ids[num_ids-1];
value.dsize -= sizeof(struct server_id);
break;
status = dbwrap_record_get_watchers(db, rec, talloc_tos(),
&ids, &num_ids);
+ if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) {
+ goto done;
+ }
if (!NT_STATUS_IS_OK(status)) {
DEBUG(1, ("dbwrap_record_get_watchers failed: %s\n",
nt_errstr(status)));
return status;
}
rec = dbwrap_fetch_locked(state->db, mem_ctx, state->key);
- if (req == NULL) {
+ if (rec == NULL) {
return NT_STATUS_INTERNAL_DB_ERROR;
}
*prec = rec;