aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2013-01-06 05:22:34 -0800
committerWladimir J. van der Laan <laanwj@gmail.com>2013-01-06 05:22:34 -0800
commit51b05d0dca1310a7c5c61e1b3a84285bbeb71eb2 (patch)
tree71f9feee341bb4dfcf324a966b5ef5eed354f19b
parent13013f5044959e2829006b18d5190116a99c1a6b (diff)
parent8ffbd6c3789843cb024a3ee425ac4cc0482eaeb7 (diff)
Merge pull request #2147 from Diapolo/mq_name_testnet
Bitcoin-Qt: give testnet a unique IPC message queue name
-rw-r--r--src/qt/bitcoin.cpp11
-rw-r--r--src/qt/qtipcserver.cpp15
-rw-r--r--src/qt/qtipcserver.h10
3 files changed, 25 insertions, 11 deletions
diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp
index dbdfade0b1..c3701ced7f 100644
--- a/src/qt/bitcoin.cpp
+++ b/src/qt/bitcoin.cpp
@@ -113,6 +113,14 @@ static void handleRunawayException(std::exception *e)
#ifndef BITCOIN_QT_TEST
int main(int argc, char *argv[])
{
+ // Command-line options take precedence:
+ ParseParameters(argc, argv);
+
+ if(GetBoolArg("-testnet")) // Separate message queue name for testnet
+ strBitcoinURIQueueName = BITCOINURI_QUEUE_NAME_TESTNET;
+ else
+ strBitcoinURIQueueName = BITCOINURI_QUEUE_NAME_MAINNET;
+
// Do this early as we don't want to bother initializing if we are just calling IPC
ipcScanRelay(argc, argv);
@@ -126,9 +134,6 @@ int main(int argc, char *argv[])
// Install global event filter that makes sure that long tooltips can be word-wrapped
app.installEventFilter(new GUIUtil::ToolTipToRichTextFilter(TOOLTIP_WRAP_THRESHOLD, &app));
- // Command-line options take precedence:
- ParseParameters(argc, argv);
-
// ... then bitcoin.conf:
if (!boost::filesystem::is_directory(GetDataDir(false)))
{
diff --git a/src/qt/qtipcserver.cpp b/src/qt/qtipcserver.cpp
index b26c37581c..2777fab852 100644
--- a/src/qt/qtipcserver.cpp
+++ b/src/qt/qtipcserver.cpp
@@ -26,6 +26,9 @@ using namespace boost;
using namespace boost::interprocess;
using namespace boost::posix_time;
+// holds Bitcoin-Qt message queue name (initialized in bitcoin.cpp)
+std::string strBitcoinURIQueueName;
+
#if defined MAC_OSX || defined __FreeBSD__
// URI handling not implemented on OSX yet
@@ -46,7 +49,7 @@ static bool ipcScanCmd(int argc, char *argv[], bool fRelay)
{
const char *strURI = argv[i];
try {
- boost::interprocess::message_queue mq(boost::interprocess::open_only, BITCOINURI_QUEUE_NAME);
+ boost::interprocess::message_queue mq(boost::interprocess::open_only, strBitcoinURIQueueName.c_str());
if (mq.try_send(strURI, strlen(strURI), 0))
fSent = true;
else if (fRelay)
@@ -76,7 +79,7 @@ static void ipcThread(void* pArg)
{
// Make this thread recognisable as the GUI-IPC thread
RenameThread("bitcoin-gui-ipc");
-
+
try
{
ipcThread2(pArg);
@@ -112,7 +115,7 @@ static void ipcThread2(void* pArg)
}
// Remove message queue
- message_queue::remove(BITCOINURI_QUEUE_NAME);
+ message_queue::remove(strBitcoinURIQueueName.c_str());
// Cleanup allocated memory
delete mq;
}
@@ -125,7 +128,7 @@ void ipcInit(int argc, char *argv[])
unsigned int nPriority = 0;
try {
- mq = new message_queue(open_or_create, BITCOINURI_QUEUE_NAME, 2, MAX_URI_LENGTH);
+ mq = new message_queue(open_or_create, strBitcoinURIQueueName.c_str(), 2, MAX_URI_LENGTH);
// Make sure we don't lose any bitcoin: URIs
for (int i = 0; i < 2; i++)
@@ -140,10 +143,10 @@ void ipcInit(int argc, char *argv[])
}
// Make sure only one bitcoin instance is listening
- message_queue::remove(BITCOINURI_QUEUE_NAME);
+ message_queue::remove(strBitcoinURIQueueName.c_str());
delete mq;
- mq = new message_queue(open_or_create, BITCOINURI_QUEUE_NAME, 2, MAX_URI_LENGTH);
+ mq = new message_queue(open_or_create, strBitcoinURIQueueName.c_str(), 2, MAX_URI_LENGTH);
}
catch (interprocess_exception &ex) {
printf("ipcInit() - boost interprocess exception #%d: %s\n", ex.get_error_code(), ex.what());
diff --git a/src/qt/qtipcserver.h b/src/qt/qtipcserver.h
index cccf200b2d..f775f272c2 100644
--- a/src/qt/qtipcserver.h
+++ b/src/qt/qtipcserver.h
@@ -1,8 +1,14 @@
#ifndef QTIPCSERVER_H
#define QTIPCSERVER_H
-// Define Bitcoin-Qt message queue name
-#define BITCOINURI_QUEUE_NAME "BitcoinURI"
+#include <string>
+
+// Define Bitcoin-Qt message queue name for mainnet
+#define BITCOINURI_QUEUE_NAME_MAINNET "BitcoinURI"
+// Define Bitcoin-Qt message queue name for testnet
+#define BITCOINURI_QUEUE_NAME_TESTNET "BitcoinURI-testnet"
+
+extern std::string strBitcoinURIQueueName;
void ipcScanRelay(int argc, char *argv[]);
void ipcInit(int argc, char *argv[]);