Skip to content

Commit

Permalink
Added debugging code for YRepo (bsc#1231323)
Browse files Browse the repository at this point in the history
  • Loading branch information
shundhammer committed Oct 23, 2024
1 parent f2e89d7 commit 2dd2847
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 14 deletions.
9 changes: 8 additions & 1 deletion src/PkgFunctions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ PkgFunctions::~PkgFunctions ()
base_product = NULL;
}

#if 1
y2milestone("Clearing repos...");
repos.clear();
y2milestone("...done.");
y2milestone("repos.size(): %d", (int) repos.size());
#endif

if (repo_manager)
{
y2milestone("Releasing the repo manager...");
Expand All @@ -158,7 +165,7 @@ PkgFunctions::~PkgFunctions ()
{
y2milestone("Releasing the zypp pointer...");
zypp_pointer = NULL;
y2milestone("Zypp pointer released");
y2milestone("Zypp pointer released.");
}
}

Expand Down
39 changes: 29 additions & 10 deletions src/PkgModule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ struct YaSTZyppLogger : public zypp::base::LogControl::LineWriter
{
virtual void writeOut( const std::string & formated_r )
{
// don't log empty (debug) messages
// don't log empty (debug) messages
if (!formated_r.empty())
{
y2lograw((formated_r+"\n").c_str());
Expand Down Expand Up @@ -65,17 +65,10 @@ PkgModule* PkgModule::instance ()
{
if (current_pkg == NULL)
{
y2milestone("Redirecting ZYPP log to y2log");

boost::shared_ptr<YaSTZyppLogger> myLogger( new YaSTZyppLogger );
zypp::base::LogControl::instance().setLineWriter( myLogger );

boost::shared_ptr<YaSTZyppFormatter> myFormatter( new YaSTZyppFormatter );
zypp::base::LogControl::instance().setLineFormater( myFormatter );

registerZyppLogger();
current_pkg = new PkgModule ();
}

return current_pkg;
}

Expand All @@ -98,8 +91,34 @@ void PkgModule::destroy()
{
if (current_pkg != NULL)
{
unregisterZyppLogger();

y2debug("Deleting PkgModule object...");
delete current_pkg;
current_pkg = NULL;
}
}


void PkgModule::registerZyppLogger()
{
y2milestone("Redirecting ZYPP log to y2log");

boost::shared_ptr<YaSTZyppLogger> myLogger( new YaSTZyppLogger );
zypp::base::LogControl::instance().setLineWriter( myLogger );

boost::shared_ptr<YaSTZyppFormatter> myFormatter( new YaSTZyppFormatter );
zypp::base::LogControl::instance().setLineFormater( myFormatter );
}


void PkgModule::unregisterZyppLogger()
{
y2milestone("Closing down ZYPP logger");

zypp::base::LogControl::instance().setLineWriter( NULL );
zypp::base::LogControl::instance().setLineFormater( NULL );

y2milestone("ZYPP logger closed down.");
}

4 changes: 4 additions & 0 deletions src/PkgModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ class PkgModule : public PkgModuleFunctions
static void destroy();

private:

static void registerZyppLogger();
static void unregisterZyppLogger();

static PkgModule* current_pkg;

};
Expand Down
43 changes: 41 additions & 2 deletions src/YRepo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,59 @@

IMPL_PTR_TYPE(YRepo);

static int yrepo_no = 0;

YRepo::YRepo(zypp::RepoInfo & repo)
: _repo(repo), _deleted(false), _loaded(false)
{}
{
_url = _repo.url().asString();
_repo_no = ++yrepo_no;

if ( _url.empty() )
_url = "<empty>";

y2milestone("Creating YRepo #%d for %s", _repo_no, _url.c_str());
}

YRepo::YRepo()
{
_url = "<default CTOR>";
_repo_no = ++yrepo_no;

y2milestone("YRepo #%d default CTOR ", _repo_no);
}


YRepo::YRepo(const YRepo &other)
{
_repo_no = ++yrepo_no;
_url = other.debugUrl();

y2milestone("Copying YRepo #%d from #%d for %s", _repo_no, other.debugNo(), _url.c_str());
}


YRepo::~YRepo()
{
y2milestone("Deleting YRepo #%d for %s", _repo_no, _url.c_str());

if (_maccess)
{
try { _maccess->release(); }
y2milestone("Releasing MediaAccess for YRepo #%d for %s", _repo_no, _url.c_str());

try
{
y2milestone("Before _maccess->release()");
_maccess->release();
y2milestone("After_maccess->release()");
}
catch (const zypp::media::MediaException & ex)
{
y2error("Error in ~Yrepo(): %s", ex.asString().c_str());
}
}

y2milestone("DONE ~YRepo #%d for %s", _repo_no, _url.c_str());
}

zypp::MediaSetAccess_Ptr & YRepo::mediaAccess()
Expand Down
7 changes: 6 additions & 1 deletion src/YRepo.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ class YRepo : public zypp::base::ReferenceCounted
zypp::MediaSetAccess_Ptr _maccess;
bool _deleted;
bool _loaded;
std::string _url;
int _repo_no;

YRepo() {}
YRepo();
YRepo(const YRepo &other);

public:
YRepo(zypp::RepoInfo & repo);
Expand All @@ -57,6 +60,8 @@ class YRepo : public zypp::base::ReferenceCounted
bool isLoaded() {return _loaded;}
void setLoaded() {_loaded = true;}
void resetLoaded() {_loaded = false;}
std::string debugUrl() const { return _url; }
int debugNo() const { return _repo_no; }

public:
static const YRepo NOREPO;
Expand Down

0 comments on commit 2dd2847

Please sign in to comment.