Skip to content

Cfg file no more watched after reconfiguration #612

Description

@RusYus

If DOMConfigurator::configureAndWatch() called more than ones no XMLWatchdog thread is created.
This happens because when old xdog is deleted it removes task in its dtor, so old thread in ThreadUtility::priv_data::doPeriodicTasks() finishes since jobs list is empty. On the next configuration new thread isn't created in ThreadUtility::addPeriodicTask because the old thread is joinable, so code goes to m_priv->interrupt.notify_one(); which does nothing.

Minimal code example to see if the watcher is running:

#include <iostream>
#include <log4cxx/logger.h>
#include <log4cxx/xml/domconfigurator.h>
#include <log4cxx/logmanager.h>

static auto logger = log4cxx::Logger::getLogger("MyApp");

int main()
{
    log4cxx::xml::DOMConfigurator::configureAndWatch((std::string)"c:\\tmp\\log4cxx.xml");

    int c = std::getchar();
    while (c != 'q')
    {
        if (c == 'c')
        {
            std::cout << "configure\n";
            log4cxx::xml::DOMConfigurator::configureAndWatch((std::string)"c:\\tmp\\log4cxx.xml");
        }

        c = std::getchar();
    }

    log4cxx::LogManager::shutdown();

    return 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions