Commit a1a4de32 authored by jan.koester's avatar jan.koester
Browse files

test

parent df9264c0
Loading
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -1895,6 +1895,8 @@ namespace authdb {
                    domain = curformdat.value;
            }

            std::cerr << "[LOGIN] user='" << username << "' domain='" << domain << "'" << std::endl;

            if (password.empty() || username.empty())
                throw AuthBackendError("login: password or username are empty!");

@@ -1919,6 +1921,7 @@ namespace authdb {

            User user;
            size_t rd = sizeof(authdb::AuthHeader), end = backend->end();
            std::cerr << "[LOGIN] scanning backend: rd=" << rd << " end=" << end << std::endl;

            while (rd + sizeof(AuthData::Record) <= end) {
                std::shared_ptr<authdb::AuthData::Record> cur = std::make_shared<authdb::AuthData::Record>();
@@ -1934,6 +1937,10 @@ namespace authdb {
                    size_t upos = sizeof(authdb::AuthHeader);
                    user.info(*backend, udat, upos);

                    std::cerr << "[LOGIN] found user='" << udat.getUsername()
                              << "' match=" << (username == udat.getUsername())
                              << " pw_match=" << (pwhash == udat.getPwHash()) << std::endl;

                    if (!username.empty() && username == udat.getUsername() &&
                        !pwhash.empty() && pwhash == udat.getPwHash()) {

+3 −0
Original line number Diff line number Diff line
@@ -248,6 +248,8 @@ namespace authdb {
                }

                if(_AdminBackend.end()<=sizeof(authdb::AuthHeader)){
                    std::cerr << "[AUTHDB] wizard check: end=" << _AdminBackend.end()
                              << " header=" << sizeof(authdb::AuthHeader) << std::endl;
                    AuthBackend::Guard admlock(_AdminBackend);
                    try{
                        WizzardEvent(curreq,tid,args);
@@ -260,6 +262,7 @@ namespace authdb {
                            rep.send(curreq,e.what(),e.what().length());
                            return;
                        }
                        std::cerr << "[AUTHDB] wizard done, end=" << _AdminBackend.end() << std::endl;
                    }
                }

+20 −1
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@
#include <algorithm>
#include <thread>
#include <chrono>
#include <map>
#include <tuple>

#include <crypto/sha.h>
#include <netplus/exception.h>
@@ -37,6 +39,12 @@
#include "cluster.h"
#include "../cluster.h"

#ifndef NDEBUG
#define DBG_LOG(x) do { std::cerr << x; } while(0)
#else
#define DBG_LOG(x) do {} while(0)
#endif

namespace authdb {

    uint64_t ClusterBackend::domainGroupId() const {
@@ -80,6 +88,8 @@ namespace authdb {
            return;

        uint64_t dgid = domainGroupId();
        DBG_LOG("[CLUSTER-BE] fetchFromCluster domain=" << _Domain
                  << " buf_size=" << _Buffer.size() << " dirty=" << _Dirty.load() << "\n");

        // Only fetch from peers every 5 seconds
        std::vector<uint8_t> peer_data;
@@ -210,18 +220,27 @@ namespace authdb {

    void ClusterBackend::lock() {
        bool was_dirty = _Dirty.load();
        DBG_LOG("[CLUSTER-BE] lock() 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
        if (!was_dirty)
            _Dirty = false;
    }

    void ClusterBackend::unlock() {
        DBG_LOG("[CLUSTER-BE] unlock() domain=" << _Domain
                  << " buf_size=" << _Buffer.size() << " dirty=" << _Dirty.load() << "\n");
        if (_Dirty) {
            newRevesion();
            uint64_t dgid = domainGroupId();
            if (pushToClusterAsync(dgid, _Buffer))
            if (pushToClusterAsync(dgid, _Buffer)) {
                DBG_LOG("[CLUSTER-BE] unlock() push OK\n");
                _Dirty = false;
            } else {
                DBG_LOG("[CLUSTER-BE] unlock() push FAILED, dirty stays true\n");
            }
            // If push failed, _Dirty stays true so next unlock() retries
        }
    }