void DigestTreeScene::plot(QString rootDigest) { clear(); shared_ptr<TreeLayout> layout(new OneLevelTreeLayout()); layout->setSiblingDistance(100); layout->setLevelDistance(100); std::vector<TreeLayout::Coordinate> childNodesCo(m_roster.size()); layout->setOneLevelLayout(childNodesCo); plotEdge(childNodesCo, NODE_SIZE); plotNode(childNodesCo, rootDigest, NODE_SIZE); m_previouslyUpdatedUser = DisplayUserNullPtr; }
void *clientManagement(void *context) { char *buffer; int clientFd, threadErr, bytesRead, nLines, index, messageReceived, nSwitches, testRange, mode; unsigned id; pthread_t snmp_thread; //Initializing variables threadErr = 0; bytesRead = 0; nSwitches = 0; nLines = 0; index = 0; mode = 0; testRange = 0; messageReceived = 0; id = *((unsigned int *)context); clientFd = reports[id].sock; buffer = NULL; while (1) { buffer = readSocket(clientFd, 2, 1, &bytesRead); if (strcmp(buffer, CONNECT_REQUEST_MESSAGE) == 0) { printf("CONNECT_REQUEST_MESSAGE\n"); pthread_mutex_lock(&lock); clientsStatuses.connected++; printf("Connected: %d/%d\n", clientsStatuses.connected, clientsStatuses.quantity); if (clientsStatuses.connected == clientsStatuses.quantity) { printf("Broadcasting 'send START_MESSAGE' order\n"); pthread_cond_broadcast(&sendStart); } while(clientsStatuses.connected < clientsStatuses.quantity){ //TODO: Agregar un timeout para enviar el mensaje aun si no estan todos conectados printf("Blocked slave id: %d. of %d\n", clientsStatuses.connected, clientsStatuses.quantity); pthread_cond_wait(&sendStart, &lock); } if (id == clientsStatuses.quantity - 1) { threadErr = pthread_create(&snmp_thread, NULL, &asynchronousSnmp, NULL); if (threadErr) { pthread_join(snmp_thread, NULL); perror("Creating SNMP thread"); exit(1); } } pthread_mutex_unlock(&lock); snprintf(buffer, strlen(START_MESSAGE) + 1, START_MESSAGE); bytesRead = writeSocket(clientFd, buffer, 2, 1); if (bytesRead < 0) { perror("connectReqMessage"); exit(0); } messageReceived++; } else if (strcmp(buffer, REPORT_MESSAGE) == 0) { printf("REPORT_MESSAGE\n"); pthread_mutex_lock(&lock); clientsStatuses.reported++; printf("Reported: %d/%d\n", clientsStatuses.reported, clientsStatuses.quantity); pthread_mutex_unlock(&lock); printf("******** RESULTS *********\n"); //REPORT ENVIRONMENT buffer = readSocketLimiter(clientFd, 5, &bytesRead); nSwitches = atoi(buffer); printf("nSwitches: %d\n", nSwitches); buffer = NULL; buffer = readSocketLimiter(clientFd, 5, &bytesRead); nLines = atoi(buffer); printf("nLines/loops: %d\n", nLines); buffer = NULL; buffer = readSocketLimiter(clientFd, 5, &bytesRead); mode = atoi(buffer); printf("mode: %d\n", mode); buffer = NULL; buffer = readSocketLimiter(clientFd, 5, &bytesRead); testRange = atoi(buffer); printf("testRange: %d\n", testRange); //REPORT DATA bytesRead = plotNode(clientFd, id, nSwitches, nLines, mode, testRange); if (bytesRead > 0) messageReceived++; } else { perror("ERROR unknown message from node"); } if (messageReceived == SERVER_MESSAGES) break; } pthread_mutex_lock(&lock); snmpStop = 1; pthread_mutex_unlock(&lock); if (id == clientsStatuses.quantity - 1) { pthread_join(snmp_thread, NULL); } //displayMessages(mysnmp, SNMP); pthread_exit(NULL); }