eARCONTROLLER_ERROR ARCONTROLLER_Network_StopNetworkThreads (ARCONTROLLER_Network_t *networkController) { // -- Stop the Network receiver and transmitter Threads -- eARCONTROLLER_ERROR error = ARCONTROLLER_OK; // Check parameters if (networkController == NULL) { error = ARCONTROLLER_ERROR_BAD_PARAMETER; } // No Else: the checking parameters sets error to ARNETWORK_ERROR_BAD_PARAMETER and stop the processing if (error == ARCONTROLLER_OK) { ARNETWORK_Manager_Stop(networkController->networkManager); if (networkController->rxThread != NULL) { ARSAL_Thread_Join(networkController->rxThread, NULL); ARSAL_Thread_Destroy(&(networkController->rxThread)); networkController->rxThread = NULL; } if (networkController->txThread != NULL) { ARSAL_Thread_Join(networkController->txThread, NULL); ARSAL_Thread_Destroy(&(networkController->txThread)); networkController->txThread = NULL; } } return error; }
int main(int argc, char **argv) { ARSAL_Thread_t server, client; ARSAL_PRINT(ARSAL_PRINT_WARNING, __TAG__, "create threads\n"); ARSAL_Thread_Create(&server, thread_server, NULL); ARSAL_Thread_Create(&client, thread_client, NULL); ARSAL_Thread_Join(server, NULL); ARSAL_Thread_Join(client, NULL); ARSAL_PRINT(ARSAL_PRINT_DEBUG, __TAG__, "destroy threads\n"); ARSAL_Thread_Destroy(&server); ARSAL_Thread_Destroy(&client); return 0; }
void IHM_Delete (IHM_t **ihm) { // Clean up if (ihm != NULL) { if ((*ihm) != NULL) { (*ihm)->run = 0; if ((*ihm)->inputThread != NULL) { ARSAL_Thread_Join((*ihm)->inputThread, NULL); ARSAL_Thread_Destroy(&((*ihm)->inputThread)); (*ihm)->inputThread = NULL; } delwin((*ihm)->mainWindow); (*ihm)->mainWindow = NULL; endwin(); refresh(); free (*ihm); (*ihm) = NULL; } } }
void stopNetwork (BD_MANAGER_t *deviceManager) { int failed = 0; eARNETWORK_ERROR netError = ARNETWORK_OK; eARNETWORKAL_ERROR netAlError = ARNETWORKAL_OK; int pingDelay = 0; // 0 means default, -1 means no ping ARSAL_PRINT(ARSAL_PRINT_INFO, TAG, "- Stop ARNetwork"); // ARNetwork cleanup if (deviceManager->netManager != NULL) { printf("Stop Manager Network !! \n"); ARNETWORK_Manager_Stop(deviceManager->netManager); if (deviceManager->rxThread != NULL) { printf("Detruit le thread rx !! \n"); ARSAL_Thread_Join(deviceManager->rxThread, NULL); ARSAL_Thread_Destroy(&(deviceManager->rxThread)); deviceManager->rxThread = NULL; } if (deviceManager->txThread != NULL) { printf("Detruit le thread tx !! \n"); ARSAL_Thread_Join(deviceManager->txThread, NULL); ARSAL_Thread_Destroy(&(deviceManager->txThread)); deviceManager->txThread = NULL; } } if (deviceManager->alManager != NULL) { printf("Arrête le manager Networkal et ferme la connexion wifi !! \n"); ARNETWORKAL_Manager_Unlock(deviceManager->alManager); ARNETWORKAL_Manager_CloseWifiNetwork(deviceManager->alManager); } printf("Supprime les managers\n"); ARNETWORK_Manager_Delete(&(deviceManager->netManager)); ARNETWORKAL_Manager_Delete(&(deviceManager->alManager)); }
eARCONTROLLER_ERROR ARCONTROLLER_Network_StopReaderThreads (ARCONTROLLER_Network_t *networkController) { // -- Stop the reader Threads -- eARCONTROLLER_ERROR error = ARCONTROLLER_OK; // Check parameters if (networkController == NULL) { error = ARCONTROLLER_ERROR_BAD_PARAMETER; } // No Else: the checking parameters sets error to ARNETWORK_ERROR_BAD_PARAMETER and stop the processing if (error == ARCONTROLLER_OK) { if (networkController->readerThreads != NULL) { // Stop reader Threads int readerThreadIndex = 0; for (readerThreadIndex = 0 ; readerThreadIndex < networkController->networkConfig.numberOfDeviceToControllerCommandsBufferIds ; readerThreadIndex++) { if (networkController->readerThreads[readerThreadIndex] != NULL) { ARSAL_Thread_Join (networkController->readerThreads[readerThreadIndex], NULL); ARSAL_Thread_Destroy (&(networkController->readerThreads[readerThreadIndex])); networkController->readerThreads[readerThreadIndex] = NULL; } } // free reader thread array free (networkController->readerThreads); networkController->readerThreads = NULL; } if (networkController->readerThreadsData != NULL) { // free reader thread data array free (networkController->readerThreadsData); networkController->readerThreadsData = NULL; } } return error; }