Commit 9aee4e0e authored by jan.koester's avatar jan.koester
Browse files

tets

parent cd7e6d1d
Loading
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -71,6 +71,9 @@ void authdb::AuthBackend::write(const unsigned char* dest, size_t destsize){
}

void authdb::AuthBackend::lock(){
    // Prefetch cluster data BEFORE acquiring the exclusive lock.
    // This avoids blocking all other threads while waiting for network I/O.
    _Api->prefetch();
    _Lock.lock();
    try {
        _Api->lock();
+1 −0
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ namespace authdb{
    public:
        virtual void write(const unsigned char *dest,size_t destsize)=0;
        virtual void read(unsigned char *src,size_t srcsize)=0;
        virtual void prefetch(){}
        virtual void lock()=0;
        virtual void unlock()=0;
        virtual void setPos(size_t pos)=0;
+12 −4
Original line number Diff line number Diff line
@@ -240,17 +240,25 @@ namespace authdb {
        _Dirty = true;
    }

    void ClusterBackend::lock() {
    void ClusterBackend::prefetch() {
        // Called BEFORE the exclusive lock is acquired.
        // Performs the blocking network fetch so other threads
        // are not blocked waiting on cluster I/O.
        bool was_dirty = _Dirty.load();
        DBG_LOG("[CLUSTER-BE] lock() domain=" << _Domain
        DBG_LOG("[CLUSTER-BE] prefetch() domain=" << _Domain
                  << " buf_size=" << _Buffer.size() << " dirty=" << was_dirty << "\n");
        fetchFromCluster();
        DBG_LOG("[CLUSTER-BE] lock() after fetch buf_size=" << _Buffer.size() << "\n");
        // fetchFromCluster/vacuum may set _Dirty; restore if no user writes pending
        DBG_LOG("[CLUSTER-BE] prefetch() after fetch buf_size=" << _Buffer.size() << "\n");
        if (!was_dirty)
            _Dirty = false;
    }

    void ClusterBackend::lock() {
        DBG_LOG("[CLUSTER-BE] lock() domain=" << _Domain
                  << " buf_size=" << _Buffer.size() << " dirty=" << _Dirty.load() << "\n");
        // Network fetch already done in prefetch(), nothing blocking here.
    }

    void ClusterBackend::unlock() {
        DBG_LOG("[CLUSTER-BE] unlock() domain=" << _Domain
                  << " buf_size=" << _Buffer.size() << " dirty=" << _Dirty.load() << "\n");
+1 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ namespace authdb {
        void write(const unsigned char *dest, size_t destsize);
        void read(unsigned char *src, size_t srcsize);

        void prefetch() override;
        void lock();
        void unlock();