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

Commit

Permalink
Change shared_ptr to boost::shared_ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
anand devan committed Aug 27, 2020
1 parent fcd294f commit 9a043b9
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 90 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
AC_PREREQ(2.52)
AC_INIT([scribe], [1.5.0])
AC_CONFIG_MACRO_DIR([aclocal])
AM_INIT_AUTOMAKE([foreign -Wall])
#AM_INIT_AUTOMAKE([foreign -Wall])
# To install locally
FB_INITIALIZE([localinstall])
AC_PREFIX_DEFAULT([/usr/local])
Expand Down
26 changes: 13 additions & 13 deletions src/conn_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ string ConnPool::makeKey(const string& hostname, unsigned long port) {

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

bool ConnPool::open(const string &service, const server_vector_t &servers, int timeout) {
return openCommon(service,
shared_ptr<scribeConn>(new scribeConn(service, servers, timeout)));
boost::shared_ptr<scribeConn>(new scribeConn(service, servers, timeout)));
}

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

int ConnPool::send(const string& hostname, unsigned long port,
shared_ptr<logentry_vector_t> messages) {
boost::shared_ptr<logentry_vector_t> messages) {
return sendCommon(makeKey(hostname, port), messages);
}

int ConnPool::send(const string &service,
shared_ptr<logentry_vector_t> messages) {
boost::shared_ptr<logentry_vector_t> messages) {
return sendCommon(service, messages);
}

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

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

Expand All @@ -96,7 +96,7 @@ bool ConnPool::openCommon(const string &key, shared_ptr<scribeConn> conn) {
pthread_mutex_lock(&mapMutex);
conn_map_t::iterator iter = connMap.find(key);
if (iter != connMap.end()) {
shared_ptr<scribeConn> old_conn = (*iter).second;
boost::shared_ptr<scribeConn> old_conn = (*iter).second;
if (old_conn->isOpen()) {
old_conn->addRef();
RETURN(true);
Expand All @@ -105,7 +105,7 @@ bool ConnPool::openCommon(const string &key, shared_ptr<scribeConn> conn) {
LOG_OPER("CONN_POOL: switching to a new connection <%s>", key.c_str());
conn->setRef(old_conn->getRef());
conn->addRef();
// old connection will be magically deleted by shared_ptr
// old connection will be magically deleted by boost::shared_ptr
connMap[key] = conn;
RETURN(true);
}
Expand Down Expand Up @@ -142,7 +142,7 @@ void ConnPool::closeCommon(const string &key) {
}

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

socket = serviceBased ?
shared_ptr<TSocket>(new TSocketPool(serverList)) :
shared_ptr<TSocket>(new TSocket(remoteHost, remotePort));
boost::shared_ptr<TSocket>(new TSocketPool(serverList)) :
boost::shared_ptr<TSocket>(new TSocket(remoteHost, remotePort));

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

framedTransport = shared_ptr<TFramedTransport>(new TFramedTransport(socket));
framedTransport = boost::shared_ptr<TFramedTransport>(new TFramedTransport(socket));
if (!framedTransport) {
throw std::runtime_error("Failed to create framed transport");
}
protocol = shared_ptr<TBinaryProtocol>(new TBinaryProtocol(framedTransport));
protocol = boost::shared_ptr<TBinaryProtocol>(new TBinaryProtocol(framedTransport));
if (!protocol) {
throw std::runtime_error("Failed to create protocol");
}
protocol->setStrict(false, false);
resendClient = shared_ptr<scribeClient>(new scribeClient(protocol));
resendClient = boost::shared_ptr<scribeClient>(new scribeClient(protocol));
if (!resendClient) {
throw std::runtime_error("Failed to create network client");
}
Expand Down
2 changes: 1 addition & 1 deletion src/dynamic_bucket_updater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ bool DynamicBucketUpdater::updateInternal(
catMap_.erase(catIter);
}

shared_ptr<TSocket> socket = shared_ptr<TSocket>(
boost::shared_ptr<TSocket> socket = boost::shared_ptr<TSocket>(
new TSocket(remoteHost, remotePort));

if (!socket) {
Expand Down
58 changes: 29 additions & 29 deletions src/scribe_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ using namespace std;

using boost::shared_ptr;

shared_ptr<scribeHandler> g_Handler;
boost::shared_ptr<scribeHandler> g_Handler;

#define DEFAULT_CHECK_PERIOD 5
#define DEFAULT_MAX_MSG_PER_SECOND 0
Expand Down Expand Up @@ -109,7 +109,7 @@ int main(int argc, char **argv) {
// seed random number generation with something reasonably unique
srand(time(NULL) ^ getpid());

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

scribe::startServer(); // never returns
Expand Down Expand Up @@ -242,10 +242,10 @@ bool scribeHandler::createCategoryFromModel(
return false;
}

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

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

shared_ptr<store_list_t> pstores;
boost::shared_ptr<store_list_t> pstores;
category_map_t::iterator cat_iter = categories.find(category);
if (cat_iter == categories.end()) {
pstores = shared_ptr<store_list_t>(new store_list_t);
pstores = boost::shared_ptr<store_list_t>(new store_list_t);
categories[category] = pstores;
} else {
pstores = cat_iter->second;
Expand Down Expand Up @@ -292,7 +292,7 @@ bool scribeHandler::throttleRequest(const vector<LogEntry>& messages) {
for (category_map_t::iterator cat_iter = categories.begin();
cat_iter != categories.end();
++cat_iter) {
shared_ptr<store_list_t> pstores = cat_iter->second;
boost::shared_ptr<store_list_t> pstores = cat_iter->second;
if (!pstores) {
throw std::logic_error("throttle check: iterator in category map holds null pointer");
}
Expand All @@ -315,10 +315,10 @@ bool scribeHandler::throttleRequest(const vector<LogEntry>& messages) {
}

// Should be called while holding a writeLock on scribeHandlerLock
shared_ptr<store_list_t> scribeHandler::createNewCategory(
boost::shared_ptr<store_list_t> scribeHandler::createNewCategory(
const string& category) {

shared_ptr<store_list_t> store_list;
boost::shared_ptr<store_list_t> store_list;

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

shared_ptr<store_list_t> pstores = cat_prefix_iter->second;
boost::shared_ptr<store_list_t> pstores = cat_prefix_iter->second;
for (store_list_t::iterator store_iter = pstores->begin();
store_iter != pstores->end(); ++store_iter) {
createCategoryFromModel(category, *store_iter);
Expand Down Expand Up @@ -368,7 +368,7 @@ shared_ptr<store_list_t> scribeHandler::createNewCategory(
// Add this message to every store in list
void scribeHandler::addMessage(
const LogEntry& entry,
const shared_ptr<store_list_t>& store_list) {
const boost::shared_ptr<store_list_t>& store_list) {

int numstores = 0;

Expand Down Expand Up @@ -416,7 +416,7 @@ ResultCode scribeHandler::Log(const vector<LogEntry>& messages) {
continue;
}

shared_ptr<store_list_t> store_list;
boost::shared_ptr<store_list_t> store_list;
string category = (*msg_iter).category;

category_map_t::iterator cat_iter;
Expand Down Expand Up @@ -496,7 +496,7 @@ bool scribeHandler::throttleDeny(int num_messages) {

void scribeHandler::stopStores() {
setStatus(STOPPING);
shared_ptr<store_list_t> store_list;
boost::shared_ptr<store_list_t> store_list;
for (store_list_t::iterator store_iter = defaultStores.begin();
store_iter != defaultStores.end(); ++store_iter) {
if (!(*store_iter)->isModelStore()) {
Expand Down Expand Up @@ -652,9 +652,9 @@ void scribeHandler::initialize() {
// Configures the store specified by the store configuration. Returns false if failed.
bool scribeHandler::configureStore(pStoreConf store_conf, int *numstores) {
string category;
shared_ptr<StoreQueue> pstore;
boost::shared_ptr<StoreQueue> pstore;
vector<string> category_list;
shared_ptr<StoreQueue> model;
boost::shared_ptr<StoreQueue> model;
bool single_category = true;


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

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

if (!result) {
Expand All @@ -734,7 +734,7 @@ bool scribeHandler::configureStore(pStoreConf store_conf, int *numstores) {


// Configures the store specified by the store configuration and category.
shared_ptr<StoreQueue> scribeHandler::configureStoreCategory(
boost::shared_ptr<StoreQueue> scribeHandler::configureStoreCategory(
pStoreConf store_conf, //configuration for store
const string &category, //category name
const boost::shared_ptr<StoreQueue> &model, //model to use (optional)
Expand All @@ -745,7 +745,7 @@ shared_ptr<StoreQueue> scribeHandler::configureStoreCategory(

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

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

// look for the store in the current list
shared_ptr<StoreQueue> pstore;
boost::shared_ptr<StoreQueue> pstore;

try {
if (model != NULL) {
// Create a copy of the model if we want a new thread per category
if (newThreadPerCategory && !is_default && !is_prefix_category) {
pstore = shared_ptr<StoreQueue>(new StoreQueue(model, category));
pstore = boost::shared_ptr<StoreQueue>(new StoreQueue(model, category));
} else {
pstore = model;
already_created = true;
Expand All @@ -798,7 +798,7 @@ shared_ptr<StoreQueue> scribeHandler::configureStoreCategory(
is_model = newThreadPerCategory && categories;

pstore =
shared_ptr<StoreQueue>(new StoreQueue(type, store_name, checkPeriod,
boost::shared_ptr<StoreQueue>(new StoreQueue(type, store_name, checkPeriod,
is_model, multi_category));
}
} catch (...) {
Expand All @@ -809,7 +809,7 @@ shared_ptr<StoreQueue> scribeHandler::configureStoreCategory(
string errormsg("Bad config - can't create a store of type: ");
errormsg += type;
setStatusDetails(errormsg);
return shared_ptr<StoreQueue>();
return boost::shared_ptr<StoreQueue>();
}

// open store. and configure it if not copied from a model
Expand All @@ -826,23 +826,23 @@ shared_ptr<StoreQueue> scribeHandler::configureStoreCategory(
LOG_OPER("Creating default store");
defaultStores.push_back(pstore);
} else if (is_prefix_category) {
shared_ptr<store_list_t> pstores;
boost::shared_ptr<store_list_t> pstores;
category_map_t::iterator category_iter = category_prefixes.find(category);
if (category_iter != category_prefixes.end()) {
pstores = category_iter->second;
} else {
pstores = shared_ptr<store_list_t>(new store_list_t);
pstores = boost::shared_ptr<store_list_t>(new store_list_t);
category_prefixes[category] = pstores;
}
pstores->push_back(pstore);
} else if (!pstore->isModelStore()) {
// push the new store onto the new map if it's not just a model
shared_ptr<store_list_t> pstores;
boost::shared_ptr<store_list_t> pstores;
category_map_t::iterator category_iter = categories.find(category);
if (category_iter != categories.end()) {
pstores = category_iter->second;
} else {
pstores = shared_ptr<store_list_t>(new store_list_t);
pstores = boost::shared_ptr<store_list_t>(new store_list_t);
categories[category] = pstores;
}
pstores->push_back(pstore);
Expand All @@ -857,7 +857,7 @@ void scribeHandler::deleteCategoryMap(category_map_t& cats) {
for (category_map_t::iterator cat_iter = cats.begin();
cat_iter != cats.end();
++cat_iter) {
shared_ptr<store_list_t> pstores = cat_iter->second;
boost::shared_ptr<store_list_t> pstores = cat_iter->second;
if (!pstores) {
throw std::logic_error("deleteCategoryMap: "
"iterator in category map holds null pointer");
Expand Down
Loading

0 comments on commit 9a043b9

Please sign in to comment.