commit
94b422154c
|
@ -42,14 +42,15 @@ void (*taosSchedFp[128])(SSchedMsg *msg) = {0};
|
||||||
void *taosProcessSchedQueue(void *param);
|
void *taosProcessSchedQueue(void *param);
|
||||||
void taosCleanUpScheduler(void *param);
|
void taosCleanUpScheduler(void *param);
|
||||||
|
|
||||||
void *taosInitScheduler(int queueSize, int numOfThreads, char *label) {
|
void *taosInitScheduler(int queueSize, int numOfThreads, const char *label) {
|
||||||
pthread_attr_t attr;
|
pthread_attr_t attr;
|
||||||
SSchedQueue * pSched = (SSchedQueue *)malloc(sizeof(SSchedQueue));
|
SSchedQueue * pSched = (SSchedQueue *)malloc(sizeof(SSchedQueue));
|
||||||
|
|
||||||
memset(pSched, 0, sizeof(SSchedQueue));
|
memset(pSched, 0, sizeof(SSchedQueue));
|
||||||
pSched->queueSize = queueSize;
|
pSched->queueSize = queueSize;
|
||||||
pSched->numOfThreads = numOfThreads;
|
pSched->numOfThreads = numOfThreads;
|
||||||
strcpy(pSched->label, label);
|
strncpy(pSched->label, label, sizeof(pSched->label)); // fix buffer overflow
|
||||||
|
pSched->label[sizeof(pSched->label)-1] = '\0';
|
||||||
|
|
||||||
if (pthread_mutex_init(&pSched->queueMutex, NULL) < 0) {
|
if (pthread_mutex_init(&pSched->queueMutex, NULL) < 0) {
|
||||||
pError("init %s:queueMutex failed, reason:%s", pSched->label, strerror(errno));
|
pError("init %s:queueMutex failed, reason:%s", pSched->label, strerror(errno));
|
||||||
|
@ -167,4 +168,5 @@ void taosCleanUpScheduler(void *param) {
|
||||||
|
|
||||||
free(pSched->queue);
|
free(pSched->queue);
|
||||||
free(pSched->qthread);
|
free(pSched->qthread);
|
||||||
|
free(pSched); // fix memory leak
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue