Fixed potential deadlocks in GUI code.
[novacoin.git] / doc / coding.txt
index 4707476..ec31ccd 100644 (file)
@@ -39,3 +39,47 @@ v       vector or similar list objects
 map     map or multimap\r
 set     set or multiset\r
 bn      CBigNum\r
+\r
+-------------------------\r
+Locking/mutex usage notes\r
+\r
+The code is multi-threaded, and uses mutexes and the CRITICAL_BLOCK/TRY_CRITICAL_BLOCK macros to protect data structures.\r
+\r
+Deadlocks due to inconsistent lock ordering (thread 1 locks cs_main and then cs_wallet, while thread 2 locks them in the opposite order: result, deadlock as each waits for the other to release its lock) are a problem. Compile with -DDEBUG_LOCKORDER to get lock order inconsistencies reported in the debug.log file.\r
+\r
+Re-architecting the core code so there are better-defined interfaces between the various components is a goal, with any necessary locking done by the components (e.g. see the self-contained CKeyStore class and its cs_KeyStore lock for example).\r
+\r
+-------\r
+Threads\r
+\r
+StartNode : Starts other threads.\r
+\r
+ThreadGetMyExternalIP : Determines outside-the-firewall IP address, sends addr message to connected peers when it determines it.\r
+\r
+ThreadIRCSeed : Joins IRC bootstrapping channel, watching for new peers and advertising this node's IP address.\r
+\r
+ThreadSocketHandler : Sends/Receives data from peers on port 8333.\r
+\r
+ThreadMessageHandler : Higher-level message handling (sending and receiving).\r
+\r
+ThreadOpenConnections : Initiates new connections to peers.\r
+\r
+ThreadTopUpKeyPool : replenishes the keystore's keypool.\r
+\r
+ThreadCleanWalletPassphrase : re-locks an encrypted wallet after user has unlocked it for a period of time.\r
+\r
+SendingDialogStartTransfer : used by pay-via-ip-address code (obsolete)\r
+\r
+ThreadDelayedRepaint : repaint the gui \r
+\r
+ThreadFlushWalletDB : Close the wallet.dat file if it hasn't been used in 500ms.\r
+\r
+ThreadRPCServer : Remote procedure call handler, listens on port 8332 for connections and services them.\r
+\r
+ThreadBitcoinMiner : Generates bitcoins\r
+\r
+ThreadMapPort : Universal plug-and-play startup/shutdown\r
+\r
+Shutdown : Does an orderly shutdown of everything\r
+\r
+ExitTimeout : Windows-only, sleeps 5 seconds then exits application\r