HACK debug g_lock del store
authorStefan Metzmacher <metze@samba.org>
Wed, 20 Dec 2017 19:38:58 +0000 (20:38 +0100)
committerStefan Metzmacher <metze@samba.org>
Tue, 29 Oct 2019 13:33:03 +0000 (14:33 +0100)
source3/lib/g_lock.c

index ef6bbb52613b901d446f24ba30b86d62b7478c67..0fd14950f077c4823e0e1d21ca5b67516f03be60 100644 (file)
@@ -108,6 +108,15 @@ static void g_lock_rec_del(struct g_lock *lck, size_t i)
        lck->num_recs -= 1;
        if (i < lck->num_recs) {
                uint8_t *recptr = lck->recsbuf + i*G_LOCK_REC_LENGTH;
+               struct g_lock_rec rec;
+               struct server_id_buf tmp;
+
+               g_lock_rec_get(&rec, recptr);
+               DBG_ERR("%s: i[%zu] pid[%s] type[%u]\n",
+                       __location__, i,
+                       server_id_str_buf(rec.pid, &tmp),
+                       (unsigned)rec.lock_type);
+
                memcpy(recptr, lck->recsbuf + lck->num_recs*G_LOCK_REC_LENGTH,
                       G_LOCK_REC_LENGTH);
        }
@@ -118,7 +127,7 @@ static NTSTATUS g_lock_store(struct db_record *rec, struct g_lock *lck,
 {
        uint8_t sizebuf[4];
        uint8_t addbuf[G_LOCK_REC_LENGTH];
-
+       size_t i;
        struct TDB_DATA dbufs[] = {
                { .dptr = sizebuf, .dsize = sizeof(sizebuf) },
                { .dptr = lck->recsbuf,
@@ -127,9 +136,27 @@ static NTSTATUS g_lock_store(struct db_record *rec, struct g_lock *lck,
                { .dptr = lck->data, .dsize = lck->datalen }
        };
 
+       for (i=0; i < lck->num_recs; i++) {
+               uint8_t *recptr = lck->recsbuf + i*G_LOCK_REC_LENGTH;
+               struct g_lock_rec _rec;
+               struct server_id_buf tmp;
+
+               g_lock_rec_get(&_rec, recptr);
+               DBG_ERR("%s: i[%zu] pid[%s] type[%u]\n",
+                       __location__, i,
+                       server_id_str_buf(_rec.pid, &tmp),
+                       (unsigned)_rec.lock_type);
+       }
+
        if (add != NULL) {
+               struct server_id_buf tmp;
                g_lock_rec_put(addbuf, *add);
 
+               DBG_ERR("%s: ia[%zu] pid[%s] type[%u]\n",
+                       __location__, lck->num_recs,
+                       server_id_str_buf(add->pid, &tmp),
+                       (unsigned)add->lock_type);
+
                dbufs[2] = (TDB_DATA) {
                        .dptr = addbuf, .dsize = G_LOCK_REC_LENGTH
                };
@@ -137,6 +164,8 @@ static NTSTATUS g_lock_store(struct db_record *rec, struct g_lock *lck,
                lck->num_recs += 1;
        }
 
+               DBG_ERR("%s: num_recs[%zu]\n",
+                       __location__, lck->num_recs);
        SIVAL(sizebuf, 0, lck->num_recs);
 
        return dbwrap_record_storev(rec, dbufs, ARRAY_SIZE(dbufs), 0);
@@ -205,6 +234,12 @@ static NTSTATUS g_lock_trylock(struct db_record *rec, struct server_id self,
        NTSTATUS status;
        bool modified = false;
        bool ok;
+       struct server_id_buf tmp;
+
+       DBG_ERR("%s: self[%s] type[%u]\n",
+               __location__,
+               server_id_str_buf(self, &tmp),
+               (unsigned)type);
 
        data = dbwrap_record_get_value(rec);
 
@@ -324,6 +359,13 @@ done:
                        status = store_status;
                }
        }
+
+       DBG_ERR("%s: self[%s] type[%u] => modified[%u] %s\n",
+               __location__,
+               server_id_str_buf(self, &tmp),
+               (unsigned)type, modified,
+               nt_errstr(status));
+
        return status;
 }