Fix "Abort trap 6" bug

- Added CCriticalSection LOCK
- Removed the use of uv_mutex_lock
This commit is contained in:
Braydon Fuller 2015-08-03 16:10:58 -04:00
parent 34de8bc602
commit 286f917dd0

View File

@ -90,7 +90,6 @@ init(Handle<Object>);
* Private Global Variables * Private Global Variables
* Used only by bitcoindjs functions. * Used only by bitcoindjs functions.
*/ */
static uv_mutex_t txmon_mutex;
static std::vector<std::string> txmon_messages; static std::vector<std::string> txmon_messages;
static uv_async_t txmon_async; static uv_async_t txmon_async;
static Eternal<Function> txmon_callback; static Eternal<Function> txmon_callback;
@ -235,7 +234,9 @@ txmon(uv_async_t *handle) {
Isolate* isolate = Isolate::GetCurrent(); Isolate* isolate = Isolate::GetCurrent();
HandleScope scope(isolate); HandleScope scope(isolate);
uv_mutex_lock(&txmon_mutex); {
LOCK(cs_main);
Local<Array> results = Array::New(isolate); Local<Array> results = Array::New(isolate);
int arrayIndex = 0; int arrayIndex = 0;
@ -256,7 +257,7 @@ txmon(uv_async_t *handle) {
txmon_messages.clear(); txmon_messages.clear();
uv_mutex_unlock(&txmon_mutex); }
} }
@ -316,10 +317,11 @@ process_messages(CNode* pfrom) {
string txHash = tx.GetHash().GetHex(); string txHash = tx.GetHash().GetHex();
uv_mutex_lock(&txmon_mutex); {
LOCK(cs_main);
txmon_messages.push_back(txHash); txmon_messages.push_back(txHash);
uv_mutex_unlock(&txmon_mutex);
uv_async_send(&txmon_async); uv_async_send(&txmon_async);
}
} }