diff --git a/xptMiner/global.h b/xptMiner/global.h index 5ffa90d..90858c8 100644 --- a/xptMiner/global.h +++ b/xptMiner/global.h @@ -28,6 +28,7 @@ #define EnterCriticalSection(Section) pthread_mutex_unlock(Section) #define LeaveCriticalSection(Section) pthread_mutex_unlock(Section) #define InitializeCriticalSection(Section) pthread_mutex_init(Section, NULL) +#define DestroyCriticalSection(Section) pthread_mutex_destroy(Section) // lazy workaround typedef int SOCKET; diff --git a/xptMiner/main.cpp b/xptMiner/main.cpp index 258377f..a17586c 100644 --- a/xptMiner/main.cpp +++ b/xptMiner/main.cpp @@ -663,7 +663,9 @@ void xptMiner_xptQueryWorkLoop() { // initiate new connection EnterCriticalSection(&cs_xptClient); + xptClient_free(xptClient); xptClient = xptMiner_initateNewXptConnectionObject(); + if(minerSettings.requestTarget.donationPercent > 0.1f) { //xptClient_addDeveloperFeeEntry(xptClient, "MK6n2VZZBpQrqpP9rtzsC9PRi5t1qsWuGc", getFeeFromDouble(minerSettings.requestTarget.donationPercent / 2.0)); @@ -851,6 +853,14 @@ void xptMiner_parseCommandline(int argc, char **argv) } } +void sig_catch(int sig,void (*f)()) +{ + struct sigaction sa; + sa.sa_handler = f; + sa.sa_flags = 0; + sigemptyset(&sa.sa_mask); + sigaction(sig,&sa,(struct sigaction *) 0); +} int main(int argc, char** argv) { @@ -890,7 +900,7 @@ sysctl(mib, 2, &numcpu, &len, NULL, 0); GetSystemInfo( &sysinfo ); numcpu = sysinfo.dwNumberOfProcessors; #endif - + sig_catch(SIGPIPE,SIG_IGN); commandlineInput.numThreads = numcpu; commandlineInput.numThreads = std::min(std::max(commandlineInput.numThreads, 1), 4); xptMiner_parseCommandline(argc, argv); diff --git a/xptMiner/xptClient.cpp b/xptMiner/xptClient.cpp index 7ad52a7..619acaf 100644 --- a/xptMiner/xptClient.cpp +++ b/xptMiner/xptClient.cpp @@ -133,6 +133,8 @@ void xptClient_free(xptClient_t* xptClient) { xptPacketbuffer_free(xptClient->sendBuffer); xptPacketbuffer_free(xptClient->recvBuffer); + DestroyCriticalSection(&xptClient->cs_workAccess); + DestroyCriticalSection(&xptClient->cs_shareSubmit); if( xptClient->clientSocket != SOCKET_ERROR ) { closesocket(xptClient->clientSocket); @@ -630,4 +632,4 @@ void xptClient_foundShare(xptClient_t* xptClient, xptShareToSubmit_t* xptShareTo EnterCriticalSection(&xptClient->cs_shareSubmit); simpleList_add(xptClient->list_shareSubmitQueue, xptShareToSubmit); LeaveCriticalSection(&xptClient->cs_shareSubmit); -} \ No newline at end of file +}