From 4bd32ce31e5920d245ae3732d06adcaff725a276 Mon Sep 17 00:00:00 2001 From: sageweil Date: Tue, 11 Sep 2007 03:00:18 +0000 Subject: [PATCH] trace repetition weirdness git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1824 29311d96-e01e-0410-9327-a35deaab8ce9 --- trunk/ceph/client/SyntheticClient.cc | 4 +++- trunk/ceph/client/Trace.cc | 30 ++++++++++------------------ trunk/ceph/client/Trace.h | 10 ++++++---- 3 files changed, 20 insertions(+), 24 deletions(-) diff --git a/trunk/ceph/client/SyntheticClient.cc b/trunk/ceph/client/SyntheticClient.cc index c822f6e55a8cd..25623b75dc2c9 100644 --- a/trunk/ceph/client/SyntheticClient.cc +++ b/trunk/ceph/client/SyntheticClient.cc @@ -688,7 +688,7 @@ int SyntheticClient::run() utime_t lat = g_clock.now(); lat -= start; - dout(1) << " trace " << tfile << " loop " << (i+1) << "/" << iarg1 << " done in " << (double)lat << " seconds" << dendl; + dout(0) << " trace " << tfile << " loop " << (i+1) << "/" << iarg1 << " done in " << (double)lat << " seconds" << dendl; if (client_logger && i > 0 && i < iarg1-1 @@ -1283,6 +1283,8 @@ int SyntheticClient::play_trace(Trace& t, string& prefix, bool metadata_only) } } + dout(10) << "trace finished on line " << t.get_line() << dendl; + // wait for safe after an object trace safegref->finish(0); delete safegref; diff --git a/trunk/ceph/client/Trace.cc b/trunk/ceph/client/Trace.cc index 2ee4d0dbc6022..31bb1c4cf5c4a 100644 --- a/trunk/ceph/client/Trace.cc +++ b/trunk/ceph/client/Trace.cc @@ -33,32 +33,24 @@ using namespace __gnu_cxx; -// -Trace::Trace(const char* f) -{ - filename = f; -} - -Trace::~Trace() -{ - fs.close(); -} - void Trace::start() { - //cout << "start" << endl; - fs.close(); - fs.open(filename); - if (!fs.is_open()) { + //cout << "start" << std::endl; + delete fs; + + fs = new ifstream(); + fs->open(filename); + if (!fs->is_open()) { generic_dout(0) << "** unable to open trace file " << filename << dendl; assert(0); } generic_dout(2) << "opened traced file '" << filename << "'" << dendl; // read first line - getline(fs, line); - + getline(*fs, line); + //cout << "first line is " << line << std::endl; + _line = 1; } @@ -84,8 +76,8 @@ const char *Trace::get_string(char *buf, const char *prefix) //cout << "buf is " << buf << std::endl; // read next line (and detect eof early) _line++; - getline(fs, line); - //cout << "next line is " << line << endl; + getline(*fs, line); + //cout << "next line is " << line << std::endl; return buf; } diff --git a/trunk/ceph/client/Trace.h b/trunk/ceph/client/Trace.h index 18e04ca4b3efc..97821f4e95e56 100644 --- a/trunk/ceph/client/Trace.h +++ b/trunk/ceph/client/Trace.h @@ -34,12 +34,14 @@ using std::ifstream; class Trace { int _line; const char *filename; - ifstream fs; + ifstream *fs; string line; public: - Trace(const char* filename); - ~Trace(); + Trace(const char* f) : filename(f), fs(0) {} + ~Trace() { + delete fs; + } int get_line() { return _line; } @@ -53,7 +55,7 @@ class Trace { return atoll(get_string(buf, 0)); } bool end() { - return fs.eof(); + return !fs || fs->eof(); //return _cur == _end; } }; -- 2.39.5