Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix memory leak

git-svn-id: http://kazuho.31tools.com/svn/incline/trunk@253 4d3e2a30-9d6d-0410-bc8c-dac56cff10b3
  • Loading branch information...
commit 7869aa23b21edb7d7fa3bff6df2e354a4669d272 1 parent d5b5cf1
kazuho authored
View
13 src/incline_fw.cc
@@ -62,6 +62,19 @@ incline_fw::~incline_fw()
delete dbh_;
}
+void*
+incline_fw::run()
+{
+ try {
+ do_run();
+ } catch (domain_error& e) {
+ delete this;
+ throw;
+ }
+ delete this;
+ return NULL;
+}
+
// TODO should use vector<shared_ptr<vector<string> > >
void
incline_fw::fetch_rows(const string& cond, vector<string>& iq_ids, vector<vector<string> >& delete_pks, vector<vector<string> >& insert_rows)
View
3  src/incline_fw.h
@@ -38,8 +38,9 @@ class incline_fw {
const manager* mgr() const { return mgr_; }
manager* mgr() { return mgr_; }
const incline_def_async_qtable* def() const { return def_; }
- virtual void* run() = 0;
+ virtual void* run();
protected:
+ virtual void do_run() = 0;
void fetch_rows(const std::string& cond, std::vector<std::string>& iq_ids, std::vector<std::vector<std::string> >& delete_pks, std::vector<std::vector<std::string> >& insert_rows);
// should perform DELETE, then (INSERT|REPLACE)
void insert_rows(incline_dbms* dbh, const std::vector<std::vector<std::string> >& rows) const;
View
6 src/incline_fw_async_qtable.cc
@@ -16,8 +16,8 @@ incline_fw_async_qtable::incline_fw_async_qtable(manager* mgr,
{
}
-void*
-incline_fw_async_qtable::run()
+void
+incline_fw_async_qtable::do_run()
{
string extra_cond, last_id;
@@ -58,8 +58,6 @@ incline_fw_async_qtable::run()
// just retry
}
}
-
- return NULL;
}
bool
View
2  src/incline_fw_async_qtable.h
@@ -10,8 +10,8 @@ class incline_fw_async_qtable : public incline_fw {
std::string clear_queue_query_base_;
public:
incline_fw_async_qtable(manager* mgr, const incline_def_async_qtable* def, incline_dbms* dbh);
- virtual void* run();
protected:
+ virtual void do_run();
virtual bool do_update_rows(const std::vector<std::vector<std::string> >& delete_pks, const std::vector<std::vector<std::string> >& insert_rows);
virtual std::string do_get_extra_cond();
};
View
5 src/incline_fw_replicator.cc
@@ -42,8 +42,8 @@ incline_fw_replicator::manager::start(vector<pthread_t>& threads)
}
}
-void*
-incline_fw_replicator::run()
+void
+incline_fw_replicator::do_run()
{
incline_dbms* dest_dbh = NULL;
string last_id;
@@ -114,5 +114,4 @@ incline_fw_replicator::run()
}
delete dest_dbh;
- return NULL;
}
View
3  src/incline_fw_replicator.h
@@ -24,7 +24,8 @@ class incline_fw_replicator : public incline_fw {
const manager* mgr() const { return static_cast<const manager*>(super::mgr()); }
manager* mgr() { return static_cast<manager*>(super::mgr()); }
const incline_def_sharded* def() const { return static_cast<const incline_def_sharded*>(super::def()); }
- virtual void* run();
+protected:
+ virtual void do_run();
};
#endif
View
1  src/incline_fw_sharded.cc
@@ -145,7 +145,6 @@ incline_fw_sharded::manager::start(vector<pthread_t>& threads)
}
}
{
- // TODO call destructor on termination
incline_dbms* dbh = incline_dbms::factory_->create();
assert(dbh != NULL);
threads.push_back(start_thread(new incline_fw_sharded(this, def, dbh)));
Please sign in to comment.
Something went wrong with that request. Please try again.