Merge pull request #96 from braydonf/fixlock

Fix "Abort trap 6" bug
This commit is contained in:
Patrick Nagurny 2015-08-03 16:32:09 -04:00
commit 1e32aa36b7
1 changed files with 26 additions and 24 deletions

View File

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