Commit 20cafd38 authored by jan.koester's avatar jan.koester
Browse files

deb

parent 719a0f5b
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -155,6 +155,26 @@ if(NOT CLIENT_ONLY)
        authdb::client
    )

    add_executable(mediadb_import_cluster_test
        test/mediadb_import_cluster_test.cpp
        src/backend.cpp
        src/cluster.cpp
    )

    target_include_directories(mediadb_import_cluster_test PRIVATE
        include
        /usr/local/include/netplus
    )

    target_link_libraries(mediadb_import_cluster_test PRIVATE
        json-c::json-c
        httppp
        netplus
        uuidp::uuidp
        paritypp::paritypp
        authdb::client
    )

    add_executable(mediadb_cache_test
        test/mediadb_cache_test.cpp
        src/preview.cpp
+16 −0
Original line number Diff line number Diff line
mediadb (20260515+17) unstable; urgency=high

  * server/import (H1/H2/H3): call finish_import() BEFORE destroying the
    import session so import_running_ and cluster isImportRunning flags are
    cleared before the ImportGuardSession destructor runs
  * Fixes import status stuck at "In Progress" while import detail shows
    "Done" — the destructor's replicate_tombstones() network call could block
    for up to 120 s, keeping the flags set and exposing a use-after-free on
    active_import_session_
  * ImportGuardSession destructor: wrap replicate_tombstones() in try/catch
    to prevent exceptions from escaping the destructor
  * Fixes post-import sync_from_cluster() being skipped because the global
    isImportRunning flag was still true during destructor execution

 -- Jan Koester <jan.koester@tuxist.de>  Thu, 15 May 2026 18:00:00 +0200

mediadb (20260515+16) unstable; urgency=medium

  * Rebuild
+1 −1
Original line number Diff line number Diff line
@@ -3227,7 +3227,7 @@ std::unique_ptr<ImportSession> ClusterMediaBackend::begin_import() {
                // imported stores on other nodes during sync.
                if (!backend_.tombstones_.empty()) {
                    backend_.tombstones_.clear();
                    backend_.replicate_tombstones();
                    try { backend_.replicate_tombstones(); } catch (...) {}
                }
                flag_.store(false);
                // Sync from cluster to pick up the replicated data on this node
+6 −6
Original line number Diff line number Diff line
@@ -80,8 +80,8 @@ void MediaHttpEvent::RequestEvent(netplus::con &curcon, const int tid, ULONG_PTR
        std::string errmsg;
        bool input_finished = (state.bytes_written >= state.content_length);
        if (should_finalize_import(state, input_finished, ok, errmsg)) {
            active_imports_.erase(it);
            app_.finish_import(ok, errmsg);
            active_imports_.erase(it);
            if (ok) {
                send_response(cureq, HttpResponse::json(200,
                    [](){ auto*j=json_object_new_object();
@@ -319,16 +319,16 @@ void MediaHttpEvent::DisconnectEvent(libhttppp::HttpRequest& curreq, const int /
    // Clean up any orphaned H1 import session (client disconnected mid-upload)
    auto it = active_imports_.find(static_cast<netplus::con*>(&curreq));
    if (it != active_imports_.end()) {
        active_imports_.erase(it);
        app_.finish_import(false, "client disconnected");
        active_imports_.erase(it);
        return;
    }

    // Clean up any orphaned H2 import sessions on this connection
    for (auto h2it = h2_imports_.begin(); h2it != h2_imports_.end(); ) {
        if (h2it->first.conn == &curreq) {
            h2it = h2_imports_.erase(h2it);
            app_.finish_import(false, "client disconnected");
            h2it = h2_imports_.erase(h2it);
            return;
        } else {
            ++h2it;
@@ -585,8 +585,8 @@ void MediaHttpEvent::onH2DataChunk(libhttppp::HttpRequest &conn, uint32_t stream
    bool ok = false;
    std::string errmsg;
    if (should_finalize_import(state, endStream, ok, errmsg)) {
        h2_imports_.erase(it);
        app_.finish_import(ok, errmsg);
        h2_imports_.erase(it);

        std::string body = ok ? json_ok() : json_err(errmsg.c_str());
        uint16_t status = ok ? 200 : 500;
@@ -605,9 +605,9 @@ bool MediaHttpEvent::onH3StreamHeaders(netplus::socket *sock, uint64_t streamId,
            bool stale = (now - it->second.last_activity) > kStaleTimeout;
            bool done = it->second.session && it->second.session->done();
            if (stale || done) {
                it = h3_imports_.erase(it);
                app_.finish_import(false, stale ? "stale h3 import session"
                                                : "h3 import session finished unexpectedly");
                it = h3_imports_.erase(it);
            } else {
                ++it;
            }
@@ -654,8 +654,8 @@ void MediaHttpEvent::onH3DataChunk(netplus::socket *sock, uint64_t streamId,
    bool ok = false;
    std::string errmsg;
    if (should_finalize_import(state, fin, ok, errmsg)) {
        h3_imports_.erase(it);
        app_.finish_import(ok, errmsg);
        h3_imports_.erase(it);

        std::string body = ok ? json_ok() : json_err(errmsg.c_str());
        uint16_t status = ok ? 200 : 500;
+796 −0

File added.

Preview size limit exceeded, changes collapsed.