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

test

parent 26f81759
Loading
Loading
Loading
Loading
Loading
+16 −8
Changes for src/session.cpp: 16 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -512,10 +512,10 @@ const authdb::SessionData *authdb::ClusterSession::getSession(uuid::uuid session
                cur->setGPOResults(c_gpo);
                cur->_lastClusterSync = std::chrono::steady_clock::now();
            } else {
                // Session not in cluster — re-push it instead of removing
                std::cerr << "[SESSION] getSession: session not in cluster, re-pushing" << std::endl;
                g_Cluster->pushSession(*cur);
                cur->_lastClusterSync = std::chrono::steady_clock::now();
                // Session was removed from cluster by another node — remove locally
                std::cerr << "[SESSION] getSession: session removed from cluster, removing locally" << std::endl;
                removeLocal(sessionid);
                return nullptr;
            }
        } catch (const std::exception &e) {
            std::cerr << "[SESSION] getSession: cluster sync error: " << e.what()
@@ -550,7 +550,9 @@ const authdb::SessionData *authdb::ClusterSession::getSession(uuid::uuid session
void authdb::ClusterSession::remSession(uuid::uuid sessionid){
    // Remove from cluster on ALL nodes
    if (g_Cluster && g_Cluster->isRunning()) {
        try {
            g_Cluster->removeSessionBySid(sessionid);
        } catch (...) {}
    }
    // Remove from local cache
    std::lock_guard<std::mutex> guard(_lock);
@@ -558,11 +560,14 @@ void authdb::ClusterSession::remSession(uuid::uuid sessionid){
}

void authdb::ClusterSession::relSession(AuthBackend &backend,uuid::uuid sessionid){
    SessionData *cursess = nullptr;

    {
        std::lock_guard<std::mutex> guard(_lock);
        SessionData *cursess = findLocal(sessionid);
        cursess = findLocal(sessionid);
    }

        // Not found locally — try to import from cluster
    // Not found locally — try to import from cluster (outside lock)
    if (!cursess && g_Cluster && g_Cluster->isRunning()) {
        uuid::uuid sid, uid, did;
        std::vector<uuid::uuid> members;
@@ -572,6 +577,7 @@ void authdb::ClusterSession::relSession(AuthBackend &backend,uuid::uuid sessioni
            cursess = new SessionData(sid, uid, did, members);
            cursess->_username = c_username;
            cursess->setGPOResults(gpo_results);
            std::lock_guard<std::mutex> guard(_lock);
            appendLocal(cursess);
        }
    }
@@ -579,14 +585,16 @@ void authdb::ClusterSession::relSession(AuthBackend &backend,uuid::uuid sessioni
    if (!cursess)
        throw AuthBackendError("reload session: sessionid not found !");

    {
        std::lock_guard<std::mutex> guard(_lock);
        reloadSessionData(backend, cursess);
    }

        // Push updated data to cluster
    // Push updated data to cluster (outside lock)
    if (g_Cluster && g_Cluster->isRunning()) {
        g_Cluster->pushSession(*cursess);
    }
}
}

void authdb::ClusterSession::listSessions(std::vector<SessionInfo> &out){
    out.clear();