s3: Use dbwrap_parse_record in fetch_share_mode_unlocked
authorVolker Lendecke <vl@samba.org>
Tue, 27 Nov 2012 14:40:06 +0000 (15:40 +0100)
committerAndreas Schneider <asn@samba.org>
Wed, 28 Nov 2012 17:27:41 +0000 (18:27 +0100)
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/locking/share_mode_lock.c

index a82c44e7929f48023e21c3f29d6d9555215e3ed6..4f26099f6043893ab0d237bf9209f82575977dfe 100644 (file)
@@ -389,6 +389,15 @@ fail:
        return NULL;
 }
 
+static void fetch_share_mode_unlocked_parser(
+       TDB_DATA key, TDB_DATA data, void *private_data)
+{
+       struct share_mode_lock *lck = talloc_get_type_abort(
+               private_data, struct share_mode_lock);
+
+       lck->data = parse_share_modes(lck, data);
+}
+
 /*******************************************************************
  Get a share_mode_lock without locking the database or reference
  counting. Used by smbstatus to display existing share modes.
@@ -400,25 +409,17 @@ struct share_mode_lock *fetch_share_mode_unlocked(TALLOC_CTX *mem_ctx,
        struct share_mode_lock *lck;
        struct file_id tmp;
        TDB_DATA key = locking_key(&id, &tmp);
-       TDB_DATA data;
        NTSTATUS status;
 
-       status = dbwrap_fetch(lock_db, talloc_tos(), key, &data);
-       if (!NT_STATUS_IS_OK(status)) {
-               DEBUG(3, ("Could not fetch share entry\n"));
-               return NULL;
-       }
-       if (data.dptr == NULL) {
-               return NULL;
-       }
        lck = talloc(mem_ctx, struct share_mode_lock);
        if (lck == NULL) {
-               TALLOC_FREE(data.dptr);
+               DEBUG(0, ("talloc failed\n"));
                return NULL;
        }
-       lck->data = parse_share_modes(lck, data);
-       TALLOC_FREE(data.dptr);
-       if (lck->data == NULL) {
+       status = dbwrap_parse_record(
+               lock_db, key, fetch_share_mode_unlocked_parser, lck);
+       if (!NT_STATUS_IS_OK(status) ||
+           (lck->data == NULL)) {
                TALLOC_FREE(lck);
                return NULL;
        }