1 // Copyright (c) 2009-2012 The Bitcoin developers
2 // Distributed under the MIT/X11 software license, see the accompanying
3 // file license.txt or http://www.opensource.org/licenses/mit-license.php.
5 #include <boost/algorithm/string.hpp>
6 #include <boost/interprocess/ipc/message_queue.hpp>
7 #include <boost/tokenizer.hpp>
8 #include <boost/date_time/posix_time/posix_time.hpp>
11 #include "qtipcserver.h"
13 using namespace boost::interprocess;
14 using namespace boost::posix_time;
15 using namespace boost;
20 message_queue::remove(BITCOINURI_QUEUE_NAME);
23 void ipcThread(void* parg)
25 message_queue* mq = (message_queue*)parg;
28 unsigned int nPriority;
31 ptime d = boost::posix_time::microsec_clock::universal_time() + millisec(100);
32 if(mq->timed_receive(&strBuf, sizeof(strBuf), nSize, nPriority, d))
34 ThreadSafeHandleURI(std::string(strBuf, nSize));
49 // TODO: implement bitcoin: URI handling the Mac Way
53 // TODO: THOROUGHLY test boost::interprocess fix,
54 // and make sure there are no Windows argument-handling exploitable
62 unsigned int nPriority;
64 mq = new message_queue(open_or_create, BITCOINURI_QUEUE_NAME, 2, 256);
66 // Make sure we don't lose any bitcoin: URIs
67 for (int i = 0; i < 2; i++)
69 ptime d = boost::posix_time::microsec_clock::universal_time() + millisec(1);
70 if(mq->timed_receive(&strBuf, sizeof(strBuf), nSize, nPriority, d))
72 ThreadSafeHandleURI(std::string(strBuf, nSize));
78 // Make sure only one bitcoin instance is listening
79 message_queue::remove(BITCOINURI_QUEUE_NAME);
80 mq = new message_queue(open_or_create, BITCOINURI_QUEUE_NAME, 2, 256);
82 catch (interprocess_exception &ex) {
85 if (!CreateThread(ipcThread, mq))