From 16e7c282c6fcec8189425bd15ec9e8a4a0ee857d Mon Sep 17 00:00:00 2001 From: Peter Iannucci Date: Mon, 30 Sep 2013 14:10:24 -0400 Subject: [PATCH] Removed tabs and unneeded constructor --- config.h | 6 +-- rpc/fifo.h | 32 ++++++++-------- rpc/marshall.h | 1 - rpc/pollmgr.h | 112 +++++++++++++++++++++++++++---------------------------- rpc/thr_pool.cc | 20 +++++----- rpc/thr_pool.h | 16 ++++---- rsm_tester.pl | 22 +++++------ 7 files changed, 104 insertions(+), 105 deletions(-) diff --git a/config.h b/config.h index dc06b8a..73940a0 100644 --- a/config.h +++ b/config.h @@ -27,9 +27,9 @@ class config : public paxos_change { bool remove(const string &, lock &cfg_mutex_lock); void reconstruct(lock &cfg_mutex_lock); typedef enum { - OK, // response and same view # - VIEWERR, // response but different view # - FAILURE, // no response + OK, // response and same view # + VIEWERR, // response but different view # + FAILURE, // no response } heartbeat_t; heartbeat_t doheartbeat(const string &m, lock &cfg_mutex_lock); public: diff --git a/rpc/fifo.h b/rpc/fifo.h index 215ec5b..e3f0c38 100644 --- a/rpc/fifo.h +++ b/rpc/fifo.h @@ -6,42 +6,42 @@ // blocks enq() and deq() when queue is FULL or EMPTY template class fifo { - public: - fifo(size_t limit=0) : max_(limit) {} - bool enq(T, bool blocking=true); - void deq(T *); - bool size() { + public: + fifo(size_t limit=0) : max_(limit) {} + bool enq(T, bool blocking=true); + void deq(T *); + bool size() { lock ml(m_); return q_.size(); } - private: - list q_; + private: + list q_; mutex m_; cond non_empty_c_; // q went non-empty - cond has_space_c_; // q is not longer overfull - size_t max_; // maximum capacity of the queue, block enq threads if exceeds this limit + cond has_space_c_; // q is not longer overfull + size_t max_; // maximum capacity of the queue, block enq threads if exceeds this limit }; template bool fifo::enq(T e, bool blocking) { lock ml(m_); - while (max_ && q_.size() >= max_) { - if (!blocking) - return false; + while (max_ && q_.size() >= max_) { + if (!blocking) + return false; has_space_c_.wait(ml); - } + } q_.push_back(e); non_empty_c_.notify_one(); - return true; + return true; } template void fifo::deq(T *e) { - lock ml(m_); - while(q_.empty()) + lock ml(m_); + while(q_.empty()) non_empty_c_.wait(ml); *e = q_.front(); q_.pop_front(); diff --git a/rpc/marshall.h b/rpc/marshall.h index 0e0af8d..0fcbfaf 100644 --- a/rpc/marshall.h +++ b/rpc/marshall.h @@ -54,7 +54,6 @@ class unmarshall { bool ok_ = false; public: - unmarshall() {} unmarshall(const string &s, bool has_header) : buf_(s),index_(RPC_HEADER_SZ) { if (!has_header) diff --git a/rpc/pollmgr.h b/rpc/pollmgr.h index a082843..2da3167 100644 --- a/rpc/pollmgr.h +++ b/rpc/pollmgr.h @@ -11,75 +11,75 @@ #define MAX_POLL_FDS 128 typedef enum { - CB_NONE = 0x0, - CB_RDONLY = 0x1, - CB_WRONLY = 0x10, - CB_RDWR = 0x11, - CB_MASK = ~0x11, + CB_NONE = 0x0, + CB_RDONLY = 0x1, + CB_WRONLY = 0x10, + CB_RDWR = 0x11, + CB_MASK = ~0x11, } poll_flag; class aio_mgr { - public: - virtual void watch_fd(int fd, poll_flag flag) = 0; - virtual bool unwatch_fd(int fd, poll_flag flag) = 0; - virtual bool is_watched(int fd, poll_flag flag) = 0; - virtual void wait_ready(vector *readable, vector *writable) = 0; - virtual ~aio_mgr() {} + public: + virtual void watch_fd(int fd, poll_flag flag) = 0; + virtual bool unwatch_fd(int fd, poll_flag flag) = 0; + virtual bool is_watched(int fd, poll_flag flag) = 0; + virtual void wait_ready(vector *readable, vector *writable) = 0; + virtual ~aio_mgr() {} }; class aio_callback { - public: - virtual void read_cb(int fd) = 0; - virtual void write_cb(int fd) = 0; - virtual ~aio_callback() {} + public: + virtual void read_cb(int fd) = 0; + virtual void write_cb(int fd) = 0; + virtual ~aio_callback() {} }; class PollMgr { - public: - PollMgr(); - ~PollMgr(); + public: + PollMgr(); + ~PollMgr(); - static PollMgr *Instance(); - static PollMgr *CreateInst(); + static PollMgr *Instance(); + static PollMgr *CreateInst(); - void add_callback(int fd, poll_flag flag, aio_callback *ch); - void del_callback(int fd, poll_flag flag); - bool has_callback(int fd, poll_flag flag, aio_callback *ch); - void block_remove_fd(int fd); - void wait_loop(); + void add_callback(int fd, poll_flag flag, aio_callback *ch); + void del_callback(int fd, poll_flag flag); + bool has_callback(int fd, poll_flag flag, aio_callback *ch); + void block_remove_fd(int fd); + void wait_loop(); - static PollMgr *instance; - static int useful; - static int useless; + static PollMgr *instance; + static int useful; + static int useless; - private: + private: mutex m_; cond changedone_c_; thread th_; - aio_callback *callbacks_[MAX_POLL_FDS]; - aio_mgr *aio_; - bool pending_change_; + aio_callback *callbacks_[MAX_POLL_FDS]; + aio_mgr *aio_; + bool pending_change_; }; class SelectAIO : public aio_mgr { - public : + public : - SelectAIO(); - ~SelectAIO(); - void watch_fd(int fd, poll_flag flag); - bool unwatch_fd(int fd, poll_flag flag); - bool is_watched(int fd, poll_flag flag); - void wait_ready(vector *readable, vector *writable); + SelectAIO(); + ~SelectAIO(); + void watch_fd(int fd, poll_flag flag); + bool unwatch_fd(int fd, poll_flag flag); + bool is_watched(int fd, poll_flag flag); + void wait_ready(vector *readable, vector *writable); - private: + private: - fd_set rfds_; - fd_set wfds_; - int highfds_; - int pipefd_[2]; + fd_set rfds_; + fd_set wfds_; + int highfds_; + int pipefd_[2]; mutex m_; @@ -87,18 +87,18 @@ class SelectAIO : public aio_mgr { #ifdef __linux__ class EPollAIO : public aio_mgr { - public: - EPollAIO(); - ~EPollAIO(); - void watch_fd(int fd, poll_flag flag); - bool unwatch_fd(int fd, poll_flag flag); - bool is_watched(int fd, poll_flag flag); - void wait_ready(vector *readable, vector *writable); - - private: - int pollfd_; - struct epoll_event ready_[MAX_POLL_FDS]; - int fdstatus_[MAX_POLL_FDS]; + public: + EPollAIO(); + ~EPollAIO(); + void watch_fd(int fd, poll_flag flag); + bool unwatch_fd(int fd, poll_flag flag); + bool is_watched(int fd, poll_flag flag); + void wait_ready(vector *readable, vector *writable); + + private: + int pollfd_; + struct epoll_event ready_[MAX_POLL_FDS]; + int fdstatus_[MAX_POLL_FDS]; }; #endif /* __linux */ diff --git a/rpc/thr_pool.cc b/rpc/thr_pool.cc index 7d3cf7d..64b3263 100644 --- a/rpc/thr_pool.cc +++ b/rpc/thr_pool.cc @@ -4,30 +4,30 @@ // otherwise, addJob() simply returns false when queue is full ThrPool::ThrPool(size_t sz, bool blocking) : nthreads_(sz),blockadd_(blocking),jobq_(100*sz) { - for (size_t i=0; i job_t; class ThrPool { - public: - ThrPool(size_t sz, bool blocking=true); - ~ThrPool(); + public: + ThrPool(size_t sz, bool blocking=true); + ~ThrPool(); - bool addJob(const job_t &j); + bool addJob(const job_t &j); - private: + private: size_t nthreads_; - bool blockadd_; + bool blockadd_; - fifo jobq_; - vector th_; + fifo jobq_; + vector th_; void do_worker(); }; diff --git a/rsm_tester.pl b/rsm_tester.pl index 7f73505..c99c66f 100755 --- a/rsm_tester.pl +++ b/rsm_tester.pl @@ -159,8 +159,8 @@ sub wait_for_view_change { my $start = time(); while( (get_num_views( $log, $including ) < $num_views) and ($start + $timeout > time()) ) { - my $lastv = `grep done $log | tail -n 1`; - chomp $lastv; + my $lastv = `grep done $log | tail -n 1`; + chomp $lastv; print " Waiting for $including to be present in >=$num_views views in $log (Last view: $lastv)\n"; sleep 1; } @@ -220,10 +220,10 @@ sub start_nodes ($$){ my $command = shift; for (my $i = 0; $i < $n; $i++) { - if ($command eq "ls") { - @pid = (@pid, spawn_ls($p[0],$p[$i])); - print "Start lock_server on $p[$i]\n"; - } + if ($command eq "ls") { + @pid = (@pid, spawn_ls($p[0],$p[$i])); + print "Start lock_server on $p[$i]\n"; + } sleep 1; my @vv = @p[0..$i]; @@ -417,7 +417,7 @@ if ($do_run[5]) { foreach my $port (@lastv) { wait_for_view_change(paxos_log($port), $in_views{$port}+1, $port, 20); } - sleep 10; + sleep 10; # now check the paxos logs and make sure the logs go through the right # views @@ -547,7 +547,7 @@ if ($do_run[7]) { if ($do_run[8]) { print "test8: start 3-process lock service\n"; - start_nodes(3,"ls"); + start_nodes(3,"ls"); print "Start lock_tester $p[0]\n"; $t = spawn("./lock_tester", $p[0]); @@ -566,7 +566,7 @@ if ($do_run[8]) { if ($do_run[9]) { print "test9: start 3-process rsm, kill second slave while lock_tester is running\n"; - start_nodes(3,"ls"); + start_nodes(3,"ls"); print "Start lock_tester $p[0]\n"; $t = spawn("./lock_tester", $p[0]); @@ -596,7 +596,7 @@ if ($do_run[9]) { if ($do_run[10]) { print "test10: start 3-process rsm, kill second slave and restarts it later while lock_tester is running\n"; - start_nodes(3,"ls"); + start_nodes(3,"ls"); print "Start lock_tester $p[0]\n"; $t = spawn("./lock_tester", $p[0]); @@ -634,7 +634,7 @@ if ($do_run[10]) { if ($do_run[11]) { print "test11: start 3-process rsm, kill primary while lock_tester is running\n"; - start_nodes(3,"ls"); + start_nodes(3,"ls"); print "Start lock_tester $p[0]\n"; $t = spawn("./lock_tester", $p[0]); -- 1.7.9.5