Skip to content
This repository was archived by the owner on Jan 13, 2022. It is now read-only.

Commit 7bf41b1

Browse files
author
anand devan
committed
Change shared_ptr to boost::shared_ptr
1 parent fcd294f commit 7bf41b1

File tree

3 files changed

+79
-79
lines changed

3 files changed

+79
-79
lines changed

src/conn_pool.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ string ConnPool::makeKey(const string& hostname, unsigned long port) {
5656

5757
bool ConnPool::open(const string& hostname, unsigned long port, int timeout) {
5858
return openCommon(makeKey(hostname, port),
59-
shared_ptr<scribeConn>(new scribeConn(hostname, port, timeout)));
59+
boost::shared_ptr<scribeConn>(new scribeConn(hostname, port, timeout)));
6060
}
6161

6262
bool ConnPool::open(const string &service, const server_vector_t &servers, int timeout) {
6363
return openCommon(service,
64-
shared_ptr<scribeConn>(new scribeConn(service, servers, timeout)));
64+
boost::shared_ptr<scribeConn>(new scribeConn(service, servers, timeout)));
6565
}
6666

6767
void ConnPool::close(const string& hostname, unsigned long port) {
@@ -73,16 +73,16 @@ void ConnPool::close(const string &service) {
7373
}
7474

7575
int ConnPool::send(const string& hostname, unsigned long port,
76-
shared_ptr<logentry_vector_t> messages) {
76+
boost::shared_ptr<logentry_vector_t> messages) {
7777
return sendCommon(makeKey(hostname, port), messages);
7878
}
7979

8080
int ConnPool::send(const string &service,
81-
shared_ptr<logentry_vector_t> messages) {
81+
boost::shared_ptr<logentry_vector_t> messages) {
8282
return sendCommon(service, messages);
8383
}
8484

85-
bool ConnPool::openCommon(const string &key, shared_ptr<scribeConn> conn) {
85+
bool ConnPool::openCommon(const string &key, boost::shared_ptr<scribeConn> conn) {
8686

8787
#define RETURN(x) {pthread_mutex_unlock(&mapMutex); return(x);}
8888

@@ -96,7 +96,7 @@ bool ConnPool::openCommon(const string &key, shared_ptr<scribeConn> conn) {
9696
pthread_mutex_lock(&mapMutex);
9797
conn_map_t::iterator iter = connMap.find(key);
9898
if (iter != connMap.end()) {
99-
shared_ptr<scribeConn> old_conn = (*iter).second;
99+
boost::shared_ptr<scribeConn> old_conn = (*iter).second;
100100
if (old_conn->isOpen()) {
101101
old_conn->addRef();
102102
RETURN(true);
@@ -105,7 +105,7 @@ bool ConnPool::openCommon(const string &key, shared_ptr<scribeConn> conn) {
105105
LOG_OPER("CONN_POOL: switching to a new connection <%s>", key.c_str());
106106
conn->setRef(old_conn->getRef());
107107
conn->addRef();
108-
// old connection will be magically deleted by shared_ptr
108+
// old connection will be magically deleted by boost::shared_ptr
109109
connMap[key] = conn;
110110
RETURN(true);
111111
}
@@ -142,7 +142,7 @@ void ConnPool::closeCommon(const string &key) {
142142
}
143143

144144
int ConnPool::sendCommon(const string &key,
145-
shared_ptr<logentry_vector_t> messages) {
145+
boost::shared_ptr<logentry_vector_t> messages) {
146146
pthread_mutex_lock(&mapMutex);
147147
conn_map_t::iterator iter = connMap.find(key);
148148
if (iter != connMap.end()) {
@@ -212,8 +212,8 @@ bool scribeConn::open() {
212212
try {
213213

214214
socket = serviceBased ?
215-
shared_ptr<TSocket>(new TSocketPool(serverList)) :
216-
shared_ptr<TSocket>(new TSocket(remoteHost, remotePort));
215+
boost::shared_ptr<TSocket>(new TSocketPool(serverList)) :
216+
boost::shared_ptr<TSocket>(new TSocket(remoteHost, remotePort));
217217

218218
if (!socket) {
219219
throw std::runtime_error("Failed to create socket");
@@ -234,16 +234,16 @@ bool scribeConn::open() {
234234
*/
235235
socket->setLinger(0, 0);
236236

237-
framedTransport = shared_ptr<TFramedTransport>(new TFramedTransport(socket));
237+
framedTransport = boost::shared_ptr<TFramedTransport>(new TFramedTransport(socket));
238238
if (!framedTransport) {
239239
throw std::runtime_error("Failed to create framed transport");
240240
}
241-
protocol = shared_ptr<TBinaryProtocol>(new TBinaryProtocol(framedTransport));
241+
protocol = boost::shared_ptr<TBinaryProtocol>(new TBinaryProtocol(framedTransport));
242242
if (!protocol) {
243243
throw std::runtime_error("Failed to create protocol");
244244
}
245245
protocol->setStrict(false, false);
246-
resendClient = shared_ptr<scribeClient>(new scribeClient(protocol));
246+
resendClient = boost::shared_ptr<scribeClient>(new scribeClient(protocol));
247247
if (!resendClient) {
248248
throw std::runtime_error("Failed to create network client");
249249
}

src/scribe_server.cpp

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ int main(int argc, char **argv) {
109109
// seed random number generation with something reasonably unique
110110
srand(time(NULL) ^ getpid());
111111

112-
g_Handler = shared_ptr<scribeHandler>(new scribeHandler(port, config_file));
112+
g_Handler = boost::shared_ptr<scribeHandler>(new scribeHandler(port, config_file));
113113
g_Handler->initialize();
114114

115115
scribe::startServer(); // never returns
@@ -242,10 +242,10 @@ bool scribeHandler::createCategoryFromModel(
242242
return false;
243243
}
244244

245-
shared_ptr<StoreQueue> pstore;
245+
boost::shared_ptr<StoreQueue> pstore;
246246
if (newThreadPerCategory) {
247247
// Create a new thread/StoreQueue for this category
248-
pstore = shared_ptr<StoreQueue>(new StoreQueue(model, category));
248+
pstore = boost::shared_ptr<StoreQueue>(new StoreQueue(model, category));
249249
LOG_OPER("[%s] Creating new category store from model %s",
250250
category.c_str(), model->getCategoryHandled().c_str());
251251

@@ -258,10 +258,10 @@ bool scribeHandler::createCategoryFromModel(
258258
category.c_str(), model->getCategoryHandled().c_str());
259259
}
260260

261-
shared_ptr<store_list_t> pstores;
261+
boost::shared_ptr<store_list_t> pstores;
262262
category_map_t::iterator cat_iter = categories.find(category);
263263
if (cat_iter == categories.end()) {
264-
pstores = shared_ptr<store_list_t>(new store_list_t);
264+
pstores = boost::shared_ptr<store_list_t>(new store_list_t);
265265
categories[category] = pstores;
266266
} else {
267267
pstores = cat_iter->second;
@@ -292,7 +292,7 @@ bool scribeHandler::throttleRequest(const vector<LogEntry>& messages) {
292292
for (category_map_t::iterator cat_iter = categories.begin();
293293
cat_iter != categories.end();
294294
++cat_iter) {
295-
shared_ptr<store_list_t> pstores = cat_iter->second;
295+
boost::shared_ptr<store_list_t> pstores = cat_iter->second;
296296
if (!pstores) {
297297
throw std::logic_error("throttle check: iterator in category map holds null pointer");
298298
}
@@ -318,7 +318,7 @@ bool scribeHandler::throttleRequest(const vector<LogEntry>& messages) {
318318
shared_ptr<store_list_t> scribeHandler::createNewCategory(
319319
const string& category) {
320320

321-
shared_ptr<store_list_t> store_list;
321+
boost::shared_ptr<store_list_t> store_list;
322322

323323
// First, check the list of category prefixes for a model
324324
category_map_t::iterator cat_prefix_iter = category_prefixes.begin();
@@ -327,7 +327,7 @@ shared_ptr<store_list_t> scribeHandler::createNewCategory(
327327
if (cat_prefix_iter->first.compare(0, len-1, category, 0, len-1) == 0) {
328328
// Found a matching prefix model
329329

330-
shared_ptr<store_list_t> pstores = cat_prefix_iter->second;
330+
boost::shared_ptr<store_list_t> pstores = cat_prefix_iter->second;
331331
for (store_list_t::iterator store_iter = pstores->begin();
332332
store_iter != pstores->end(); ++store_iter) {
333333
createCategoryFromModel(category, *store_iter);
@@ -368,7 +368,7 @@ shared_ptr<store_list_t> scribeHandler::createNewCategory(
368368
// Add this message to every store in list
369369
void scribeHandler::addMessage(
370370
const LogEntry& entry,
371-
const shared_ptr<store_list_t>& store_list) {
371+
const boost::shared_ptr<store_list_t>& store_list) {
372372

373373
int numstores = 0;
374374

@@ -416,7 +416,7 @@ ResultCode scribeHandler::Log(const vector<LogEntry>& messages) {
416416
continue;
417417
}
418418

419-
shared_ptr<store_list_t> store_list;
419+
boost::shared_ptr<store_list_t> store_list;
420420
string category = (*msg_iter).category;
421421

422422
category_map_t::iterator cat_iter;
@@ -496,7 +496,7 @@ bool scribeHandler::throttleDeny(int num_messages) {
496496

497497
void scribeHandler::stopStores() {
498498
setStatus(STOPPING);
499-
shared_ptr<store_list_t> store_list;
499+
boost::shared_ptr<store_list_t> store_list;
500500
for (store_list_t::iterator store_iter = defaultStores.begin();
501501
store_iter != defaultStores.end(); ++store_iter) {
502502
if (!(*store_iter)->isModelStore()) {
@@ -652,9 +652,9 @@ void scribeHandler::initialize() {
652652
// Configures the store specified by the store configuration. Returns false if failed.
653653
bool scribeHandler::configureStore(pStoreConf store_conf, int *numstores) {
654654
string category;
655-
shared_ptr<StoreQueue> pstore;
655+
boost::shared_ptr<StoreQueue> pstore;
656656
vector<string> category_list;
657-
shared_ptr<StoreQueue> model;
657+
boost::shared_ptr<StoreQueue> model;
658658
bool single_category = true;
659659

660660

@@ -685,7 +685,7 @@ bool scribeHandler::configureStore(pStoreConf store_conf, int *numstores) {
685685
}
686686
else if (single_category) {
687687
// configure single store
688-
shared_ptr<StoreQueue> result =
688+
boost::shared_ptr<StoreQueue> result =
689689
configureStoreCategory(store_conf, category_list[0], model);
690690

691691
if (result == NULL) {
@@ -718,7 +718,7 @@ bool scribeHandler::configureStore(pStoreConf store_conf, int *numstores) {
718718
// create a store for each category
719719
vector<string>::iterator iter;
720720
for (iter = category_list.begin(); iter < category_list.end(); iter++) {
721-
shared_ptr<StoreQueue> result =
721+
boost::shared_ptr<StoreQueue> result =
722722
configureStoreCategory(store_conf, *iter, model);
723723

724724
if (!result) {
@@ -745,7 +745,7 @@ shared_ptr<StoreQueue> scribeHandler::configureStoreCategory(
745745

746746
if (category.empty()) {
747747
setStatusDetails("Bad config - store with blank category");
748-
return shared_ptr<StoreQueue>();
748+
return boost::shared_ptr<StoreQueue>();
749749
}
750750

751751
LOG_OPER("CATEGORY : %s", category.c_str());
@@ -763,17 +763,17 @@ shared_ptr<StoreQueue> scribeHandler::configureStoreCategory(
763763
string errormsg("Bad config - no type for store with category: ");
764764
errormsg += category;
765765
setStatusDetails(errormsg);
766-
return shared_ptr<StoreQueue>();
766+
return boost::shared_ptr<StoreQueue>();
767767
}
768768

769769
// look for the store in the current list
770-
shared_ptr<StoreQueue> pstore;
770+
boost::shared_ptr<StoreQueue> pstore;
771771

772772
try {
773773
if (model != NULL) {
774774
// Create a copy of the model if we want a new thread per category
775775
if (newThreadPerCategory && !is_default && !is_prefix_category) {
776-
pstore = shared_ptr<StoreQueue>(new StoreQueue(model, category));
776+
pstore = boost::shared_ptr<StoreQueue>(new StoreQueue(model, category));
777777
} else {
778778
pstore = model;
779779
already_created = true;
@@ -798,7 +798,7 @@ shared_ptr<StoreQueue> scribeHandler::configureStoreCategory(
798798
is_model = newThreadPerCategory && categories;
799799

800800
pstore =
801-
shared_ptr<StoreQueue>(new StoreQueue(type, store_name, checkPeriod,
801+
boost::shared_ptr<StoreQueue>(new StoreQueue(type, store_name, checkPeriod,
802802
is_model, multi_category));
803803
}
804804
} catch (...) {
@@ -809,7 +809,7 @@ shared_ptr<StoreQueue> scribeHandler::configureStoreCategory(
809809
string errormsg("Bad config - can't create a store of type: ");
810810
errormsg += type;
811811
setStatusDetails(errormsg);
812-
return shared_ptr<StoreQueue>();
812+
return boost::shared_ptr<StoreQueue>();
813813
}
814814

815815
// open store. and configure it if not copied from a model
@@ -826,23 +826,23 @@ shared_ptr<StoreQueue> scribeHandler::configureStoreCategory(
826826
LOG_OPER("Creating default store");
827827
defaultStores.push_back(pstore);
828828
} else if (is_prefix_category) {
829-
shared_ptr<store_list_t> pstores;
829+
boost::shared_ptr<store_list_t> pstores;
830830
category_map_t::iterator category_iter = category_prefixes.find(category);
831831
if (category_iter != category_prefixes.end()) {
832832
pstores = category_iter->second;
833833
} else {
834-
pstores = shared_ptr<store_list_t>(new store_list_t);
834+
pstores = boost::shared_ptr<store_list_t>(new store_list_t);
835835
category_prefixes[category] = pstores;
836836
}
837837
pstores->push_back(pstore);
838838
} else if (!pstore->isModelStore()) {
839839
// push the new store onto the new map if it's not just a model
840-
shared_ptr<store_list_t> pstores;
840+
boost::shared_ptr<store_list_t> pstores;
841841
category_map_t::iterator category_iter = categories.find(category);
842842
if (category_iter != categories.end()) {
843843
pstores = category_iter->second;
844844
} else {
845-
pstores = shared_ptr<store_list_t>(new store_list_t);
845+
pstores = boost::shared_ptr<store_list_t>(new store_list_t);
846846
categories[category] = pstores;
847847
}
848848
pstores->push_back(pstore);
@@ -857,7 +857,7 @@ void scribeHandler::deleteCategoryMap(category_map_t& cats) {
857857
for (category_map_t::iterator cat_iter = cats.begin();
858858
cat_iter != cats.end();
859859
++cat_iter) {
860-
shared_ptr<store_list_t> pstores = cat_iter->second;
860+
boost::shared_ptr<store_list_t> pstores = cat_iter->second;
861861
if (!pstores) {
862862
throw std::logic_error("deleteCategoryMap: "
863863
"iterator in category map holds null pointer");

0 commit comments

Comments
 (0)