Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F12944985
qtipcserver.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
qtipcserver.cpp
View Options
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
#include
<boost/algorithm/string.hpp>
#include
<boost/interprocess/ipc/message_queue.hpp>
#include
<boost/tokenizer.hpp>
#include
<boost/date_time/posix_time/posix_time.hpp>
#include
"util.h"
#include
"qtipcserver.h"
using
namespace
boost
::
interprocess
;
using
namespace
boost
::
posix_time
;
using
namespace
boost
;
using
namespace
std
;
void
ipcShutdown
()
{
message_queue
::
remove
(
BITCOINURI_QUEUE_NAME
);
}
void
ipcThread
(
void
*
parg
)
{
message_queue
*
mq
=
(
message_queue
*
)
parg
;
char
strBuf
[
257
];
size_t
nSize
;
unsigned
int
nPriority
;
loop
{
ptime
d
=
boost
::
posix_time
::
microsec_clock
::
universal_time
()
+
millisec
(
100
);
if
(
mq
->
timed_receive
(
&
strBuf
,
sizeof
(
strBuf
),
nSize
,
nPriority
,
d
))
{
ThreadSafeHandleURI
(
std
::
string
(
strBuf
,
nSize
));
Sleep
(
1000
);
}
if
(
fShutdown
)
{
ipcShutdown
();
break
;
}
}
ipcShutdown
();
}
void
ipcInit
()
{
#ifdef MAC_OSX
// TODO: implement bitcoin: URI handling the Mac Way
return
;
#endif
#ifdef WIN32
// TODO: THOROUGHLY test boost::interprocess fix,
// and make sure there are no Windows argument-handling exploitable
// problems.
return
;
#endif
message_queue
*
mq
;
char
strBuf
[
257
];
size_t
nSize
;
unsigned
int
nPriority
;
try
{
mq
=
new
message_queue
(
open_or_create
,
BITCOINURI_QUEUE_NAME
,
2
,
256
);
// Make sure we don't lose any bitcoin: URIs
for
(
int
i
=
0
;
i
<
2
;
i
++
)
{
ptime
d
=
boost
::
posix_time
::
microsec_clock
::
universal_time
()
+
millisec
(
1
);
if
(
mq
->
timed_receive
(
&
strBuf
,
sizeof
(
strBuf
),
nSize
,
nPriority
,
d
))
{
ThreadSafeHandleURI
(
std
::
string
(
strBuf
,
nSize
));
}
else
break
;
}
// Make sure only one bitcoin instance is listening
message_queue
::
remove
(
BITCOINURI_QUEUE_NAME
);
mq
=
new
message_queue
(
open_or_create
,
BITCOINURI_QUEUE_NAME
,
2
,
256
);
}
catch
(
interprocess_exception
&
ex
)
{
return
;
}
if
(
!
CreateThread
(
ipcThread
,
mq
))
{
delete
mq
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-c++
Expires
Fri, Feb 7, 16:44 (1 d, 17 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5082724
Default Alt Text
qtipcserver.cpp (2 KB)
Attached To
rABC Bitcoin ABC
Event Timeline
Log In to Comment