Thread pooling refac

This commit is contained in:
cora48 2015-03-18 17:28:39 +03:00
parent f1e8b3a568
commit 3435eab40d
6 changed files with 249 additions and 131 deletions

View File

@ -1,21 +1,59 @@
#include <Threader.h> #include <Threader.h>
std::vector<ThreadStruct> Threader::threadPool; std::vector<char*> Threader::threadPool;
int Threader::threadPoolSize;
bool Threader::mayRun;
void *Threader::lFunc;
void Threader::createThreadPool(int poolSize, void *func, ST *st) { void Threader::recreateThreadPool(int poolSize) {
for(int i = 0; i < poolSize; ++i) { if(mayRun) {
pthread_t thrc; createThreadPool(poolSize, (void* (*)(int))lFunc);
pthread_create(&thrc, NULL, (void *(*)(void*))func, st);
ThreadStruct threadStruct {
&thrc,
false
};
threadPool.push_back(threadStruct);
} }
} }
void Threader::fireThread(ST *st) { void Threader::createThreadPool(int poolSize, void *func(int)) {
cleanUp();
lFunc = (void*)func;
threadPoolSize = poolSize;
for(int i = 0; i < threadPoolSize; ++i) {
char *res = NULL;
threadPool.push_back(res);
std::thread thr12(func, i);
thr12.detach();
//#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
// _beginthread((void(*)(void*))_connect, 0, (void *)i);
//#else
// pthread_t thrc;
// pthread_create(&thrc, NULL, (void *(*)(void*))func, (void *)i);
//#endif
Sleep(1);
}
mayRun = true;
}
int Threader::getFreeDataSlotId() {
for(int i = 0; i != threadPoolSize; ++i) {
if(threadPool[i] == NULL) return i;
}
return -1;
}
int Threader::getFreeThreadId() {
int res;
while((res = getFreeDataSlotId()) < 0) Sleep(10);
return res;
}
void Threader::cleanUp() {
mayRun = false;
//for(int i = 0; i != threadPoolSize; ++i) {
//if(threadPool[i] != NULL) delete threadPool[i];
//}
threadPool.clear();
}
void Threader::fireThread(char *res) {
//while(!mayRun) sleep(10);
threadPool[getFreeThreadId()] = res;
} }

View File

@ -2,20 +2,30 @@
#define THREADER_H #define THREADER_H
#include <mainResources.h> #include <mainResources.h>
#include <thread>
struct ThreadStruct{ //typedef struct {
pthread_t *handler; // char argv[MAX_ADDR_LEN] = {0};
bool busy; //} ST;
};
class Threader { class Threader {
private:
static std::vector<ThreadStruct> threadPool;
private:
static int threadPoolSize;
static void* lFunc;
public: public:
static void createThreadPool(int poolSize, void *func, ST *st); static std::vector<char *> threadPool;
static void fireThread(ST *st); static bool mayRun;
static pthread_t getFreeThread();
private:
static int getFree();
static int getFreeDataSlotId();
static int getFreeThreadId();
public:
static void recreateThreadPool(int poolSize);
static void createThreadPool(int poolSize, void *func(int));
static void fireThread(char *st);
static void cleanUp();
}; };
#endif // THREADER_H #endif // THREADER_H

View File

@ -88,10 +88,6 @@ typedef int BOOL;
#define COOKIE_MAX_SIZE 1024 #define COOKIE_MAX_SIZE 1024
#define RESULT_DIR_NAME "./result_files-" __DATE__ #define RESULT_DIR_NAME "./result_files-" __DATE__
typedef struct {
char argv[MAX_ADDR_LEN];
} ST;
struct PathStr{ struct PathStr{
char codepage[32]; char codepage[32];
char headr[TITLE_MAX_SIZE]; char headr[TITLE_MAX_SIZE];

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.2.1, 2015-03-17T17:30:18. --> <!-- Written by QtCreator 3.2.1, 2015-03-18T17:28:02. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>

View File

@ -26,6 +26,7 @@
#include "progressbardrawer.h" #include "progressbardrawer.h"
#include "externFunctions.h" #include "externFunctions.h"
#include "externData.h" #include "externData.h"
#include "Threader.h"
QDate date = QDate::currentDate(); QDate date = QDate::currentDate();
int ver = 100*(100*(date.year()%100) + date.month()) + date.day(); int ver = 100*(100*(date.year()%100) + date.month()) + date.day();
@ -3571,6 +3572,7 @@ void nesca_3::ChangeLabelTO_ValueChanged(QString str)
void nesca_3::ChangeLabelThreads_ValueChanged(QString str) void nesca_3::ChangeLabelThreads_ValueChanged(QString str)
{ {
gThreads = str.toInt(); gThreads = str.toInt();
//Threader::recreateThreadPool(gThreads);
} }
void nesca_3::PingTO_ChangeValue(QString str) void nesca_3::PingTO_ChangeValue(QString str)

View File

@ -3,8 +3,10 @@
#include "externData.h" #include "externData.h"
#include "externFunctions.h" #include "externFunctions.h"
#include "Connector.h" #include "Connector.h"
#include "Threader.h"
#include <thread>
ST *st = NULL; //ST *st = NULL;
QJsonArray *jsonArr = new QJsonArray(); QJsonArray *jsonArr = new QJsonArray();
@ -880,31 +882,99 @@ unsigned long int numOfIps(int ipsstart[], int ipsend[])
// return res; // return res;
//} //}
//#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
//void _connect(int ss)
//#else
//void _connect(int ss)
//#endif
//{
// while(globalScanFlag) {
// while(Threader::threadPool[ss] == NULL) {
// if(!globalScanFlag) return;
// Sleep(10);
// }
// ++ipCounter;
// //char ip[MAX_ADDR_LEN] = {0};
// //strcpy(ip, Threader::threadPool[ss]);
// //char hostLog[256] = {0};
// //strcpy(hostLog, GetHost(ip));
// //delete Threader::threadPool[ss];
// ConInc();
// for(int i = 0; i <= overallPorts; ++i)
// {
// if(globalScanFlag == false) break;
// //if(Connector::_ConnectToPort( ip, portArr[i], "" ) == -2) break;
// //if(Connector::_ConnectToPort( Threader::threadPool[ss], portArr[i], "" ) == -2) break;
// };
// ConDec();
// Threader::threadPool[ss] = NULL;
// }
//}
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) #if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
void _connect(void* ss) void _connect(char* ip)
#else #else
void *_connect(void* ss) void _connect(char* ip)
#endif #endif
{ {
++ipCounter; ++ipCounter;
char ip[MAX_ADDR_LEN] = {0}; ConInc();
strcpy(ip, ((ST*)ss)->argv);
//char hostLog[256] = {0};
//strcpy(hostLog, GetHost(ip));
delete (ST*)ss;
ConInc(); for(int i = 0; i <= overallPorts; ++i)
{
if(globalScanFlag == false) break;
if(Connector::_ConnectToPort( ip, portArr[i], "" ) == -2) break;
};
for(int i = 0; i <= overallPorts; ++i) ConDec();
{
if(globalScanFlag == false) break;
if(Connector::_ConnectToPort( ip, portArr[i], "" ) == -2) break;
};
ConDec();
} }
void targetAndIPWriter(long long unsigned int target, char *buff) void targetAndIPWriter(long long unsigned int target, const char *buff)
{ {
char curIPBuff[256] = {0}, targetNPers[32] = {0}; char curIPBuff[256] = {0}, targetNPers[32] = {0};
@ -1585,7 +1655,7 @@ int fInit(int InitMode, char *gR)
if(ipsend[i] > 255) if(ipsend[i] > 255)
{ {
stt->doEmitionRedFoundData("[Error] Incorrect range."); stt->doEmitionRedFoundData("[Error] Incorrect range.");
stt->doEmitionKillSttThread(); stt->doEmitionKillSttThread();
return -1; return -1;
}; };
@ -1605,7 +1675,7 @@ int fInit(int InitMode, char *gR)
) )
) )
{ {
stt->doEmitionRedFoundData("[Error] Incorrect range."); stt->doEmitionRedFoundData("[Error] Incorrect range.");
stt->doEmitionKillSttThread(); stt->doEmitionKillSttThread();
return -1; return -1;
}; };
@ -2229,14 +2299,14 @@ int _GetDNSFromMask(char *mask, char *saveMask, char *saveMaskEnder)
} }
else else
{ {
if(globalScanFlag == false) return 0;
strcpy(endIP2, saveMask); strcpy(endIP2, saveMask);
st = new ST(); //st = new ST();
ZeroMemory(st->argv, sizeof(st->argv)); //ZeroMemory(st->argv, sizeof(st->argv));
ZeroMemory(iip, sizeof(iip)); ZeroMemory(iip, sizeof(iip));
while(cons >= gThreads && globalScanFlag) Sleep(300); while(cons >= gThreads && globalScanFlag) Sleep(300);
if(globalScanFlag == false) return 0;
strcpy(iip, mask); strcpy(iip, mask);
strcpy(saveStartIP, iip); strcpy(saveStartIP, iip);
@ -2244,19 +2314,24 @@ int _GetDNSFromMask(char *mask, char *saveMask, char *saveMaskEnder)
++indexIP; ++indexIP;
strcpy(st->argv, iip); char res[256] = {0};
strcpy(res, iip);
targetAndIPWriter(--gTargets, st->argv); targetAndIPWriter(--gTargets, res);
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) // std::thread thr(_connect, res);
if(globalScanFlag) _beginthread( (void(*)(void*))_connect, 0, st ); // thr.detach();
#else
if(globalScanFlag) //Threader::fireThread(st);
{ //#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
pthread_t thrc; // if(globalScanFlag) _beginthread( (void(*)(void*))_connect, 0, st );
pthread_create(&thrc, NULL, (void *(*)(void*))&_connect, st ); //#else
}; // if(globalScanFlag)
#endif // {
// pthread_t thrc;
// pthread_create(&thrc, NULL, (void *(*)(void*))&_connect, st );
// };
//#endif
Sleep(gThreadDelay); Sleep(gThreadDelay);
}; };
@ -2269,6 +2344,8 @@ int startScan(char* args)
OpenSSL_add_all_algorithms(); /* Load cryptos, et.al. */ OpenSSL_add_all_algorithms(); /* Load cryptos, et.al. */
SSL_load_error_strings(); /* Bring in and register error messages */ SSL_load_error_strings(); /* Bring in and register error messages */
// Threader::createThreadPool(gThreads, (void* (*)(int))_connect);
horLineFlag = false; horLineFlag = false;
flCounter = 0; flCounter = 0;
PieAnomC1 = 0, PieWF = 0, PieBA = 0, PieSusp = 0, PieLowl = 0, PieSSH = 0; PieAnomC1 = 0, PieWF = 0, PieBA = 0, PieSusp = 0, PieLowl = 0, PieSSH = 0;
@ -2309,7 +2386,7 @@ int startScan(char* args)
int resInit = fInit(gMode, gRange); int resInit = fInit(gMode, gRange);
if(resInit == -1 ) if(resInit == -1 )
{ {
stt->doEmitionRedFoundData("[Error] fInit failure"); stt->doEmitionRedFoundData("[Error] fInit failure");
stt->doEmitionKillSttThread(); stt->doEmitionKillSttThread();
return -1; return -1;
@ -2350,11 +2427,11 @@ stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads));
struct in_addr tAddr; struct in_addr tAddr;
for (unsigned long i = ip1; i <= ip2; ++i) { for (unsigned long i = ip1; i <= ip2; ++i) {
if (globalScanFlag == false) break; if (globalScanFlag == false) break;
unsigned long offset = ip2 - i; unsigned long offset = ip2 - i;
tAddr.s_addr = i; tAddr.s_addr = i;
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) #if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
ipVec.push_back(std::to_string(tAddr.S_un.S_un_b.s_b4) ipVec.push_back(std::to_string(tAddr.S_un.S_un_b.s_b4)
+ "." + std::to_string(tAddr.S_un.S_un_b.s_b3) + "." + std::to_string(tAddr.S_un.S_un_b.s_b3)
@ -2362,32 +2439,28 @@ stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads));
+ "." + std::to_string(tAddr.S_un.S_un_b.s_b1)); + "." + std::to_string(tAddr.S_un.S_un_b.s_b1));
#else #else
tAddr.s_addr = ntohl(tAddr.s_addr); tAddr.s_addr = ntohl(tAddr.s_addr);
const char *ipStr = inet_ntoa(tAddr); ipVec.push_back(inet_ntoa(tAddr));
ipVec.push_back((char*)ipStr);
#endif #endif
if (ipVec.size() >= (offset < 1000 ? offset : 1000)) { if (ipVec.size() >= (offset < 1000 ? offset : 1000)) {
std::random_shuffle(ipVec.begin(), ipVec.end()); std::random_shuffle(ipVec.begin(), ipVec.end());
while (ipVec.size() != 0) { while (ipVec.size() != 0) {
if (globalScanFlag == false) goto haters_gonna_hate_IPM;
st = new ST();
ZeroMemory(st->argv, sizeof(st->argv));
while (cons >= gThreads && globalScanFlag) Sleep(500); while (cons >= gThreads && globalScanFlag) Sleep(500);
++indexIP; if (globalScanFlag == false) goto haters_gonna_hate_IPM;
strcpy(st->argv, ipVec[0].c_str()); //st = new ST();
strcpy(saveStartIP, ipVec[0].c_str()); //ZeroMemory(st->argv, MAX_ADDR_LEN);
++indexIP;
//strcpy(st->argv, ipVec[0].c_str());
strcpy(res, ipVec[0].c_str());
strcpy(saveStartIP, res);
ipVec.erase(ipVec.begin()); ipVec.erase(ipVec.begin());
targetAndIPWriter(gTargets--, st->argv); targetAndIPWriter(gTargets--, res);
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) std::thread thr(_connect, res);
_beginthread((void(*)(void*))_connect, 0, st); thr.detach();
#else //Threader::fireThread(res);
pthread_t thrc;
pthread_create(&thrc, NULL, (void *(*)(void*))&_connect, st);
#endif
Sleep(gThreadDelay); Sleep(gThreadDelay);
} }
} }
@ -2398,12 +2471,13 @@ stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads));
} }
case false: { case false: {
struct in_addr tAddr; struct in_addr tAddr;
for (unsigned long i = ip1; i <= ip2; ++i) { for (unsigned long i = ip1; i <= ip2; ++i) {
if (globalScanFlag == false) break;
st = new ST();
ZeroMemory(st->argv, sizeof(st->argv));
ZeroMemory(res, sizeof(res));
while (cons >= gThreads && globalScanFlag) Sleep(500); while (cons >= gThreads && globalScanFlag) Sleep(500);
if (globalScanFlag == false) break;
//st = new ST();
//ZeroMemory(st->argv, sizeof(st->argv));
ZeroMemory(res, sizeof(res));
++indexIP; ++indexIP;
tAddr.s_addr = i; tAddr.s_addr = i;
@ -2413,19 +2487,19 @@ stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads));
+ "." + std::to_string(tAddr.S_un.S_un_b.s_b2) + "." + std::to_string(tAddr.S_un.S_un_b.s_b2)
+ "." + std::to_string(tAddr.S_un.S_un_b.s_b1)).c_str()); + "." + std::to_string(tAddr.S_un.S_un_b.s_b1)).c_str());
#else #else
tAddr.s_addr = ntohl(tAddr.s_addr);
strcpy(res, inet_ntoa(tAddr)); strcpy(res, inet_ntoa(tAddr));
#endif #endif
strcpy(st->argv, res); //strcpy(st->argv, res);
strcpy(saveStartIP, res); strcpy(saveStartIP, res);
targetAndIPWriter(gTargets--, st->argv); targetAndIPWriter(gTargets--, res);
// std::thread thr(_connect, res);
// thr.detach();
//Threader::fireThread(st);
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
_beginthread((void(*)(void*))_connect, 0, st);
#else
pthread_t thrc;
pthread_create(&thrc, NULL, (void *(*)(void*))&_connect, st);
#endif
Sleep(gThreadDelay); Sleep(gThreadDelay);
} }
break; break;
@ -2578,7 +2652,7 @@ stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads));
if (flCounter == 0) if (flCounter == 0)
{ {
stt->doEmitionRedFoundData("Empty IP list."); stt->doEmitionRedFoundData("Empty IP list.");
globalScanFlag = false; globalScanFlag = false;
stt->doEmitionKillSttThread(); stt->doEmitionKillSttThread();
return -1; return -1;
@ -2626,8 +2700,8 @@ stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads));
strcat(metaRange, "."); strcat(metaRange, ".");
strcat(metaRange, std::to_string(ipsendfl[gC][3]).c_str()); strcat(metaRange, std::to_string(ipsendfl[gC][3]).c_str());
unsigned long ip1 = (ipsstartfl[gC][0] * 16777216) + (ipsstartfl[gC][1] * 65536) + (ipsstartfl[gC][2] * 256) + ipsstartfl[gC][3]; unsigned long ip1 = (ipsstartfl[gC][0] * 16777216) + (ipsstartfl[gC][1] * 65536) + (ipsstartfl[gC][2] * 256) + ipsstartfl[gC][3];
unsigned long ip2 = (ipsendfl[gC][0] * 16777216) + (ipsendfl[gC][1] * 65536) + (ipsendfl[gC][2] * 256) + ipsendfl[gC][3]; unsigned long ip2 = (ipsendfl[gC][0] * 16777216) + (ipsendfl[gC][1] * 65536) + (ipsendfl[gC][2] * 256) + ipsendfl[gC][3];
switch (gShuffle) { switch (gShuffle) {
case true: { case true: {
@ -2635,39 +2709,37 @@ stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads));
struct in_addr tAddr; struct in_addr tAddr;
for (unsigned long i = ip1; i <= ip2; ++i) { for (unsigned long i = ip1; i <= ip2; ++i) {
if (globalScanFlag == false) break; if (globalScanFlag == false) break;
int offset = ip2 - i; unsigned long offset = ip2 - i;
tAddr.s_addr = i; tAddr.s_addr = i;
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) #if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
ipVec.push_back(std::to_string(tAddr.S_un.S_un_b.s_b4) + "." + std::to_string(tAddr.S_un.S_un_b.s_b3) + "." + std::to_string(tAddr.S_un.S_un_b.s_b2) + "." + std::to_string(tAddr.S_un.S_un_b.s_b1)); ipVec.push_back(std::to_string(tAddr.S_un.S_un_b.s_b4) + "." + std::to_string(tAddr.S_un.S_un_b.s_b3) + "." + std::to_string(tAddr.S_un.S_un_b.s_b2) + "." + std::to_string(tAddr.S_un.S_un_b.s_b1));
#else #else
ipVec.push_back(inet_ntoa(tAddr)); tAddr.s_addr = ntohl(tAddr.s_addr);
ipVec.push_back(inet_ntoa(tAddr));
#endif #endif
if (ipVec.size() >= (offset < 1000 ? offset : 1000)) { if (ipVec.size() >= (offset < 1000 ? offset : 1000)) {
std::random_shuffle(ipVec.begin(), ipVec.end()); std::random_shuffle(ipVec.begin(), ipVec.end());
while (ipVec.size() != 0) { while (ipVec.size() != 0) {
if (globalScanFlag == false) goto haters_gonna_hate_IM;
st = new ST();
ZeroMemory(st->argv, sizeof(st->argv));
while (cons >= gThreads && globalScanFlag) Sleep(500); while (cons >= gThreads && globalScanFlag) Sleep(500);
if (globalScanFlag == false) goto haters_gonna_hate_IM;
//st = new ST();
//ZeroMemory(st->argv, MAX_ADDR_LEN);
++indexIP; ++indexIP;
strcpy(st->argv, ipVec[0].c_str()); strcpy(res, ipVec[0].c_str());
strcpy(saveStartIP, ipVec[0].c_str()); strcpy(saveStartIP, res);
ipVec.erase(ipVec.begin()); ipVec.erase(ipVec.begin());
targetAndIPWriter(gTargets--, st->argv); targetAndIPWriter(gTargets--, res);
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) // std::thread thr(_connect, res);
_beginthread((void(*)(void*))_connect, 0, st); // thr.detach();
#else
pthread_t thrc; //Threader::fireThread(st);
pthread_create(&thrc, NULL, (void *(*)(void*))&_connect, st);
#endif
Sleep(gThreadDelay); Sleep(gThreadDelay);
} }
} }
@ -2677,33 +2749,33 @@ stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads));
} }
case false: { case false: {
struct in_addr tAddr; struct in_addr tAddr;
for (unsigned long i = ip1; i <= ip2; ++i) { for (unsigned long i = ip1; i <= ip2; ++i) {
if (globalScanFlag == false) break;
st = new ST();
ZeroMemory(st->argv, sizeof(st->argv));
ZeroMemory(res, sizeof(res));
while (cons >= gThreads && globalScanFlag) Sleep(500); while (cons >= gThreads && globalScanFlag) Sleep(500);
if (globalScanFlag == false) break;
//st = new ST();
//ZeroMemory(st->argv, sizeof(st->argv));
ZeroMemory(res, sizeof(res));
++indexIP; ++indexIP;
tAddr.s_addr = i; tAddr.s_addr = i;
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) #if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
strcpy(res, (std::to_string(tAddr.S_un.S_un_b.s_b4) + "." + std::to_string(tAddr.S_un.S_un_b.s_b3) + "." + std::to_string(tAddr.S_un.S_un_b.s_b2) + "." + std::to_string(tAddr.S_un.S_un_b.s_b1)).c_str()); strcpy(res, (std::to_string(tAddr.S_un.S_un_b.s_b4) + "." + std::to_string(tAddr.S_un.S_un_b.s_b3) + "." + std::to_string(tAddr.S_un.S_un_b.s_b2) + "." + std::to_string(tAddr.S_un.S_un_b.s_b1)).c_str());
#else #else
tAddr.s_addr = ntohl(tAddr.s_addr);
strcpy(res, inet_ntoa(tAddr)); strcpy(res, inet_ntoa(tAddr));
#endif #endif
strcpy(st->argv, res); //strcpy(st->argv, res);
strcpy(saveStartIP, res); strcpy(saveStartIP, res);
targetAndIPWriter(gTargets--, st->argv); targetAndIPWriter(gTargets--, res);
// std::thread thr(_connect, res);
// thr.detach();
//Threader::fireThread(st);
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__)
_beginthread((void(*)(void*))_connect, 0, st);
#else
pthread_t thrc;
pthread_create(&thrc, NULL, (void *(*)(void*))&_connect, st);
#endif
Sleep(gThreadDelay); Sleep(gThreadDelay);
} }
break; break;
}; };
@ -2724,8 +2796,6 @@ stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads));
while(cons > 0 || jsonArr->size() > 0) { while(cons > 0 || jsonArr->size() > 0) {
Sleep(2000); Sleep(2000);
}; };
nCleanup();
stt->doEmitionGreenFoundData("Done. Saved: " + QString::number(saved) + "; Alive: " + QString::number(found) + "."); stt->doEmitionGreenFoundData("Done. Saved: " + QString::number(saved) + "; Alive: " + QString::number(found) + ".");
stt->doEmitionChangeParsed(QString::number(saved) + "/" + QString::number(found)); stt->doEmitionChangeParsed(QString::number(saved) + "/" + QString::number(found));
@ -2734,6 +2804,8 @@ stt->doEmitionThreads(QString::number(0) + "/" + QString::number(gThreads));
} }
void nCleanup(){ void nCleanup(){
Threader::cleanUp();
if(loginLst != NULL) if(loginLst != NULL)
{ {
for(int i = 0; i < MaxLogin; ++i) delete []loginLst[i]; for(int i = 0; i < MaxLogin; ++i) delete []loginLst[i];