Dev/detach pthreads not joining (#1019)

* detach the pthreads that are not joining else memory leak

* removed the clean up comment, also refactored the pthread join/detach for ctb 1g
This commit is contained in:
maliakal_d 2024-11-07 11:24:46 +01:00 committed by GitHub
parent 06266f3905
commit 5088e5a205
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
19 changed files with 36 additions and 26 deletions

View File

@ -2209,7 +2209,8 @@ int startStateMachine() {
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
sharedMemory_setStatus(IDLE);
return FAIL;
}
} else
pthread_detach(pthread_virtual_tid);
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
return OK;
#endif

View File

@ -2572,7 +2572,8 @@ int startStateMachine() {
sharedMemory_setStatus(IDLE);
sharedMemory_unlockAcqFlag();
return FAIL;
}
} else
pthread_detach(virtual_tid);
LOG(logINFO, ("Virtual Acquisition started\n"));
sharedMemory_unlockAcqFlag();
return OK;

View File

@ -3380,7 +3380,8 @@ int startStateMachine() {
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
sharedMemory_setStatus(IDLE);
return FAIL;
}
} else
pthread_detach(pthread_virtual_tid);
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
return OK;
#endif

View File

@ -1667,7 +1667,8 @@ int startStateMachine() {
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
sharedMemory_setStatus(IDLE);
return FAIL;
}
} else
pthread_detach(pthread_virtual_tid);
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
return OK;
#endif

View File

@ -2734,7 +2734,8 @@ int startStateMachine() {
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
sharedMemory_setStatus(IDLE);
return FAIL;
}
} else
pthread_detach(pthread_virtual_tid);
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
return OK;
#endif

View File

@ -1858,7 +1858,8 @@ int startStateMachine() {
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
sharedMemory_setStatus(IDLE);
return FAIL;
}
} else
pthread_detach(pthread_virtual_tid);
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
return OK;
#endif

View File

@ -2532,7 +2532,8 @@ int startStateMachine() {
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
sharedMemory_setStatus(IDLE);
return FAIL;
}
} else
pthread_detach(pthread_virtual_tid);
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
return OK;
#endif

View File

@ -91,7 +91,7 @@ static inline void FILELOG_PrintLog(enum TLogLevel level, char *m) {
}
static inline char *FILELOG_BuildLog(const char *fmt, ...) {
char *p;
char *p = NULL;
va_list ap;
p = malloc(ERROR_MSG_LENGTH);
va_start(ap, fmt);

View File

@ -2117,7 +2117,8 @@ int acquire(int blocking, int file_des) {
// scanErrorMessage)
if (blocking || !scan) {
pthread_join(pthread_tid, NULL);
}
} else
pthread_detach(pthread_tid);
}
}
}
@ -2213,6 +2214,13 @@ void *start_state_machine(void *arg) {
ret = FAIL;
strcpy(mess, "Could not start read frames thread!\n");
LOG(logERROR, (mess));
} else {
// blocking or scan
// wait to finish reading from fifo (1g real ctb)
if (*blocking || times > 1)
pthread_join(pthread_tid_ctb_1g, NULL);
else
pthread_detach(pthread_tid_ctb_1g);
}
}
// add scan error message
@ -2229,12 +2237,6 @@ void *start_state_machine(void *arg) {
#endif
// blocking or scan
if (*blocking || times > 1) {
// wait to finish reading from fifo (1g real ctb)
#if defined(CHIPTESTBOARDD) && !defined(VIRTUAL)
if (!enableTenGigabitEthernet(-1)) {
pthread_join(pthread_tid_ctb_1g, NULL);
}
#endif
#ifdef EIGERD
waitForAcquisitionEnd(&ret, mess);
if (ret == FAIL && scan) {
@ -7861,7 +7863,6 @@ int set_pattern(int file_des) {
!defined(MYTHEN3D)
functionNotImplemented();
#else
patternParameters *pat = malloc(sizeof(patternParameters));
memset(pat, 0, sizeof(patternParameters));
// ignoring endianness for eiger
@ -8515,7 +8516,8 @@ int start_readout(int file_des) {
ret = FAIL;
strcpy(mess, "Could not start read frames thread!\n");
LOG(logERROR, (mess));
}
} else
pthread_detach(pthread_tid_ctb_1g);
}
}
#endif

View File

@ -1329,7 +1329,8 @@ int startStateMachine() {
LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
sharedMemory_setStatus(IDLE);
return FAIL;
}
} else
pthread_detach(pthread_virtual_tid);
LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
return OK;
#endif

View File

@ -2,13 +2,13 @@
// Copyright (C) 2021 Contributors to the SLS Detector Package
/** API versions */
#define RELEASE "developer"
#define APICTB "developer 0x240918"
#define APIGOTTHARD "developer 0x240918"
#define APIMOENCH "developer 0x240918"
#define APIXILINXCTB "developer 0x240918"
#define APIEIGER "developer 0x240918"
#define APIMYTHEN3 "developer 0x241001"
#define APIRECEIVER "developer 0x241014"
#define APILIB "developer 0x241021"
#define APIGOTTHARD2 "developer 0x241022"
#define APIJUNGFRAU "developer 0x241024"
#define APICTB "developer 0x241107"
#define APIGOTTHARD "developer 0x241107"
#define APIGOTTHARD2 "developer 0x241107"
#define APIJUNGFRAU "developer 0x241107"
#define APIMYTHEN3 "developer 0x241107"
#define APIMOENCH "developer 0x241107"
#define APIXILINXCTB "developer 0x241107"
#define APIEIGER "developer 0x241107"