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

test

parent d55e65da
Loading
Loading
Loading
Loading
Loading
+12 −2
Changes for src/admin.cpp: 12 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -857,10 +857,20 @@ namespace authdb {
        void apiRemoveDomain(libhttppp::HttpRequest &curreq, const char *cdid, const SessionData *sdat) {
            if (!isSuperAdmin(sdat))
                throw AuthBackendError("removeDomain: nur SuperAdmins von admin.local erlaubt!");
            AuthBackend::Guard guard(_AdminBackend);
            Domain domain;

            // Purge domain backend cluster data before removing the domain record
            uuid::uuid uuid;
            uuid.parse(cdid);
            {
                AuthBackend *domBackend = getDomain(cdid);
                if (domBackend) {
                    AuthBackend::Guard domGuard(*domBackend);
                    domBackend->purge();
                }
            }

            AuthBackend::Guard guard(_AdminBackend);
            Domain domain;
            domain.remove(_AdminBackend, uuid);

            json_object *jobj = json_object_new_object();
+4 −0
Changes for src/backend.cpp: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -109,6 +109,10 @@ void authdb::AuthBackend::vacuum(){
    _Api->vacuum();
}

void authdb::AuthBackend::purge(){
    _Api->purge();
}

authdb::AuthBackend::Guard::Guard(AuthBackend &backend) : _Backend(backend){
    _Backend.lock();
}
+3 −0
Changes for src/backend.h: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ namespace authdb{
        virtual size_t getRevesion()=0;
        virtual void newRevesion()=0;
        virtual void vacuum()=0;
        virtual void purge(){};
    };

    class VISIBILITY AuthBackend {
@@ -87,6 +88,8 @@ namespace authdb{

        void vacuum();

        void purge();

        void write(const unsigned char *dest,size_t destsize);
        void read(char unsigned *src,size_t srcsize);

+28 −0
Changes for src/backends/cluster.cpp: 28 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -328,6 +328,34 @@ namespace authdb {
        _Dirty = true;
    }

    void ClusterBackend::purge() {
        if (!g_Cluster || !g_Cluster->isRunning())
            return;

        uint64_t dgid = domainGroupId();

        // Remove from local block store
        auto &store = g_Cluster->getStore();
        store.remove_group(dgid);

        // Remove from peer nodes
        auto &client = g_Cluster->getClient();
        if (client) {
            try {
                auto &cmtx = g_Cluster->getClientMutex();
                std::unique_lock<std::timed_mutex> lock(cmtx, std::chrono::seconds(3));
                if (lock.owns_lock()) {
                    client->remove(dgid);
                }
            } catch (const std::exception &e) {
                std::cerr << "ClusterBackend::purge: peer remove failed: " << e.what() << std::endl;
            }
        }

        _Buffer.clear();
        _Dirty = false;
    }

    void ClusterBackend::vacuum() {
        if (_Buffer.size() <= sizeof(AuthHeader))
            return;
+1 −0
Changes for src/backends/cluster.h: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ namespace authdb {
        void newRevesion();

        void vacuum();
        void purge();

    private:
        uint64_t domainGroupId() const;