bitcoin/bitcoin — pull request #1023 by Diapolo (2012-04-01 12:45:15+00:00)
Title: massive URI-handling / IPC server re-work

What I try to achieve here:
- harden the URI handling / IPC server (i.e. buffer length checks use of IMPLEMENT_RANDOMIZE_STACK for the ipcThread)
- log and handle boost interprocess exceptions where possible
- make URI handling more usable / robust on Windows (and not worse on other platforms ^^)

What I achieved (running and verified on Windows):
- it's possible to start the client via URI click, if no message_queue file exists
- if one exists the clicked URI is sent to the queue file, but doesn't start the client (call to try_send() in bitcoin.cpp succeeds and we exit there - currently no check if the client is running - ideas are welcome), the URI is processed after manually starting the client and is not lost
- on Windows it's now possible to use 2 client instances in parallel and the first started one receives clicked URIs, if I close one of the instances the one left will process URIs
- URI length is limited to 255 chars as message queue message size is 256 chars max.

What I could not achieve:
- handle some special cases i.e. a BitcoinURL file get's created by a user and is placed in the boost_interprocess folder -> results in the GUI freeze bug, as the file permissions differ from what boost would set, when creating the mq file -> that causes a boost deadlock (https://svn.boost.org/trac/boost/ticket/6745)

Some details:
The message queue is not removed anymore when closing the client, as this causes massive handling problems on Windows with 2 instances and my former approach of stale mq detection. First try is always to open the mq file for a re-use. If this fails a new mq is created.

The best and most stable platform for that code is boost 1.49 with https://svn.boost.org/trac/boost/ticket/5392#comment:24 and https://github.com/bitcoin/bitcoin/pull/986 integrated into it. As I opened this before 0.7 and hope for a decent discussion on the topic.