int main(){ while(1){ printf("1)createList 2)showList 3)insertNode 4)deleteNode\n"); scanf("%d", &input); switch(input){ case 1: createList(); break; case 2: showList(); break; case 3: int insertData[2]={0,0}; *insertData = insertRequest(); node* iNode; iNode = (node*)malloc(sizeof(node)); iNode->name = insertData[0]; insertNode(iNode,insertData[1]); break; case 4: break; case 5: printf("離開程式!\n"); return 0; default: break; } } }
/** Reinitialises the network manager. This is triggered when the users * selects 'reload' in the addon manager screen. This function inserts * a high priority reinit request into the request queue. */ void NetworkHttp::insertReInit() { Request *request = new Request(Request::HC_REINIT, 9999, /*manage_memory*/true); if(UserConfigParams::logAddons()) printf("[addons] Inserting reInit request.\n"); insertRequest(request); } // insertReInit
void thrdRequest(LPVOID lpvThreadParam) { long i; bool waiting = true; CString outbuffer; char tempclock[100]; while (!exitFlag) { Sleep(4000); LogEvent("Current Process Requesting Access to Critical Section"); WaitForSingleObject(sRequest, INFINITE); WaitForSingleObject(sReply, INFINITE); WaitForSingleObject(sClock, INFINITE); insertRequest(gProcessID, myclock); for (i=1; i<= NUMBEROFPROCESSES; i++) { if (i != gProcessID) { ReplyQueue[i-1] = false; outbuffer = "REQUEST:"; outbuffer += ltoa(gProcessID,tempclock, 10); outbuffer += ":"; outbuffer += ltoa(myclock, tempclock, 10); sendMessage(outbuffer, i); } } waitingForReply = true; myclock++; ReleaseSemaphore(sClock, 1, &i); ReleaseSemaphore(sReply, 1, &i); ReleaseSemaphore(sRequest, 1, &i); while (waiting) { waiting = false; WaitForSingleObject(sReply, INFINITE); WaitForSingleObject(sAlive, INFINITE); for (i=0; i<NUMBEROFPROCESSES; i++) { if ((i+1) != gProcessID) { if (AliveQueue[i]) { if (ReplyQueue[i] == false) waiting = true; } } } ReleaseSemaphore(sAlive, 1, &i); ReleaseSemaphore(sReply, 1, &i); } waiting = true; WaitForSingleObject(sClock, INFINITE); criticalsection(); ReleaseSemaphore(sClock, 1, &i); WaitForSingleObject(sRequest, INFINITE); RequestQueue[gProcessID -1] = -1; ReleaseSemaphore(sRequest, 1, &i); } ExitThread(0); }//end of Request thread
/** External interface to download a file asynchronously. This will wake up * the thread and schedule it to download the file. The calling program has * to poll using getProgress() to find out if the download has finished. * \param url The file from the server to download. * \param save The name to save the downloaded file under. Defaults to * the name given in file. * \param priority Priority of the request (must be <=99) */ Request *NetworkHttp::downloadFileAsynchron(const std::string &url, const std::string &save, int priority, bool manage_memory) { // Limit priorities to 99 so that important system requests // (init and quit) will have highest priority. assert(priority<=99); Request *request = new Request(Request::HC_DOWNLOAD_FILE, priority, manage_memory, url, (save!="") ? save : url ); if(UserConfigParams::logAddons()) printf("[addons] Download asynchron '%s' as '%s'.\n", request->getURL().c_str(), request->getSavePath().c_str()); insertRequest(request); return request; } // downloadFileAsynchron
/** This function inserts a high priority request to quit into the request * queue of the network thead, and also aborts any ongoing download. * Separating this allows more time for the thread to finish cleanly, * before it gets cancelled in the destructor. */ void NetworkHttp::stopNetworkThread() { #ifndef NO_CURL if(UserConfigParams::m_internet_status!=NetworkHttp::IPERM_ALLOWED) return; // If a download should be active (which means it was cancelled by the // user, in which case it will still be ongoing in the background) // we can't get the mutex, and would have to wait for a timeout, // and we couldn't finish STK. This way we request an abort of // a download, which mean we can get the mutex and ask the service // thread here to cancel properly. cancelAllDownloads(); Request *r = new Request(Request::HC_QUIT, 9999); if(UserConfigParams::logAddons()) printf("[addons] Inserting QUIT request.\n"); insertRequest(r); #endif } // stopNetworkThread
// Sends the pixarray for a given slot in the circular buffer // The size of the frame we send is (rows * cols * 3) + 1. // The *3 is for the three channels per pixel (RGB) and the +1 // is an extra byte which lets the client know whether or not // more data is coming (we denote this byte as the TERM flag). // If the term flag == 1, then there is more data coming, so the // client should keep the connection open. // If the term flag == 0, then there is no more data coming, and // the client should close the connection. void sendFrame(int bufferIndex) { int i = bufferIndex; int sizeToSend = buffer[i].rows * buffer[i].cols * 3 + 1; int x, y; int rows = buffer[i].rows; int cols = buffer[i].cols; unsigned char *buf = NULL; // +1 slot used to determine if there is more data coming: 0 or 1 buf = (unsigned char *)malloc ((cols*rows*3) + 1); if (!buf) { perror("Could not malloc memory for buf\n"); exit(1); } // Place the frame data into a char array for (y = 0; y < rows; y++) { for (x = 0; x < cols; x++) { buf[(y*cols+x)*3+0] = PPM_GETR(buffer[i].pixArray[rows-y-1][x]); buf[(y*cols+x)*3+1] = PPM_GETG(buffer[i].pixArray[rows-y-1][x]); buf[(y*cols+x)*3+2] = PPM_GETB(buffer[i].pixArray[rows-y-1][x]); } } char* clientID = buffer[i].clientRequest->clientID; // Determine if this is part of a movie which was already stopped by client int inStopList = searchStopList(clientID); // clientRequest objects are shared for all frames belonging to a single // client request. Therefore, no need to make redundant copies, just pointers. // Only free this client request obj when the last frame is serviced! int deleteFlag = FALSE; // Check to see if the movie has repeat = 1, if so, there is more data to send even // though the movie is done playing. if (buffer[i].frame == 100) { // If its a repeat, and the client hasnt requested a stop movie, then copy this request again if (buffer[i].repeat == TRUE && inStopList == FALSE) { // Add a start_movie request to the request list, with repeat flag = 1 // Set the 100th frame with more data flag = 1 deleteFlag = FALSE; insertRequest(buffer[i].clientRequest); buf[cols*rows*3] = NOTCLOSE; } else { // Call deleteStopID(clientID) // Set the 100th frame with more data flag = 0 deleteStopID(clientID); buf[cols*rows*3] = CLOSE; deleteFlag = TRUE; } } // If its not the last frame else { // If it is part of a movie which was stopped, then this is the last frame // and the client should just close the connection if (inStopList == TRUE) { buf[cols*rows*3] = CLOSE; } // Otherwise this is a frame for a movie which has regular playback // so don't close the connection, just receive the movie frames else { buf[cols*rows*3] = NOTCLOSE; } } // The movie hasn't been stopped, so send the frame data if (inStopList == FALSE) { // Send the entire frame (reduces write syscalls) #ifdef DEBUG printf("Send frame: %d request string: %s\n", buffer[i].frame, buffer[i].clientRequest->requestString); #endif write(buffer[i].clientRequest->clientSD, buf, sizeToSend); if (errno == EPIPE) { #ifdef DEBUG printf("Got EPIPE error errno: %d\n", errno); #endif insertStopID(buffer[i].clientRequest->clientID); close(buffer[i].clientRequest->clientSD); errno = 0; } } // Release the memory ppm_freearray (buffer[i].pixArray, buffer[i].rows); free(buf); // If this clientRequest obj is not going to be used anymore, free if (deleteFlag == TRUE) { free(buffer[i].clientRequest); } }
Status updateShardChunks(OperationContext* opCtx, const NamespaceString& nss, const std::vector<ChunkType>& chunks, const OID& currEpoch) { invariant(!chunks.empty()); NamespaceString chunkMetadataNss(ChunkType::ShardNSPrefix + nss.ns()); try { DBDirectClient client(opCtx); /** * Here are examples of the operations that can happen on the config server to update * the config.chunks collection. 'chunks' only includes the chunks that result from the * operations, which can be read from the config server, not any that were removed, so * we must delete any chunks that overlap with the new 'chunks'. * * CollectionVersion = 10.3 * * moveChunk * {_id: 3, max: 5, version: 10.1} --> {_id: 3, max: 5, version: 11.0} * * splitChunk * {_id: 3, max: 9, version 10.3} --> {_id: 3, max: 5, version 10.4} * {_id: 5, max: 8, version 10.5} * {_id: 8, max: 9, version 10.6} * * mergeChunk * {_id: 10, max: 14, version 4.3} --> {_id: 10, max: 22, version 10.4} * {_id: 14, max: 19, version 7.1} * {_id: 19, max: 22, version 2.0} * */ for (auto& chunk : chunks) { // Check for a different epoch. if (!chunk.getVersion().hasEqualEpoch(currEpoch)) { return Status{ErrorCodes::ConflictingOperationInProgress, str::stream() << "Invalid chunks found when reloading '" << nss.toString() << "'. Previous collection epoch was '" << currEpoch.toString() << "', but unexpectedly found a new epoch '" << chunk.getVersion().epoch().toString() << "'. Collection was dropped and recreated."}; } // Delete any overlapping chunk ranges. Overlapping chunks will have a min value // ("_id") between (chunk.min, chunk.max]. // // query: { "_id" : {"$gte": chunk.min, "$lt": chunk.max}} auto deleteDocs(stdx::make_unique<BatchedDeleteDocument>()); deleteDocs->setQuery(BSON(ChunkType::minShardID << BSON( "$gte" << chunk.getMin() << "$lt" << chunk.getMax()))); deleteDocs->setLimit(0); auto deleteRequest(stdx::make_unique<BatchedDeleteRequest>()); deleteRequest->addToDeletes(deleteDocs.release()); BatchedCommandRequest batchedDeleteRequest(deleteRequest.release()); batchedDeleteRequest.setNS(chunkMetadataNss); const BSONObj deleteCmdObj = batchedDeleteRequest.toBSON(); rpc::UniqueReply deleteCommandResponse = client.runCommandWithMetadata(chunkMetadataNss.db().toString(), deleteCmdObj.firstElementFieldName(), rpc::makeEmptyMetadata(), deleteCmdObj); auto deleteStatus = getStatusFromCommandResult(deleteCommandResponse->getCommandReply()); if (!deleteStatus.isOK()) { return deleteStatus; } // Now the document can be expected to cleanly insert without overlap. auto insert(stdx::make_unique<BatchedInsertRequest>()); insert->addToDocuments(chunk.toShardBSON()); BatchedCommandRequest insertRequest(insert.release()); insertRequest.setNS(chunkMetadataNss); const BSONObj insertCmdObj = insertRequest.toBSON(); rpc::UniqueReply commandResponse = client.runCommandWithMetadata(chunkMetadataNss.db().toString(), insertCmdObj.firstElementFieldName(), rpc::makeEmptyMetadata(), insertCmdObj); auto insertStatus = getStatusFromCommandResult(commandResponse->getCommandReply()); if (!insertStatus.isOK()) { return insertStatus; } } return Status::OK(); } catch (const DBException& ex) { return ex.toStatus(); } }
/*! * \~english * Reimplemented QDataTable function. * \~russian * Переопределяет функцию QDataTable. Если контейнер wJournal, может испускаеть сигналы insertRequest(), updateRequest(), deleteRequest(), viewRequest() * \~ */ void wDBTable::contentsContextMenuEvent ( QContextMenuEvent * e ) { Q3Table::contentsContextMenuEvent( e ); QString str, ctype; if ( containerType() == "wDocument" || containerType() == "wCatalogue" ) { // Переопределяем всплывающее по правой кнопке мыши меню для табличной части документа // Во-первых, для его локализации // Во-вторых, чтобы добавляемая в табличную часть строка всегда вставлялась самой последней. enum { IdInsert=0, IdUpdate, IdDelete, }; QPointer<Q3PopupMenu> popupForDoc = new Q3PopupMenu( this ); int id[ 3 ]; id[ IdInsert ] = popupForDoc->insertItem( tr( "New" ) ); id[ IdUpdate ] = popupForDoc->insertItem( tr( "Edit" ) ); id[ IdDelete ] = popupForDoc->insertItem( tr( "Delete" ) ); if ( !sqlCursor() || isReadOnly() || !numCols() ) { popupForDoc->setItemEnabled(id[ IdInsert ], false ); popupForDoc->setItemEnabled(id[ IdUpdate ], false ); popupForDoc->setItemEnabled(id[ IdDelete ], false ); } int r = popupForDoc->exec( e->globalPos() ); delete (Q3PopupMenu*) popupForDoc; if(r==id[IdInsert]) { beginInsert(); } else if(r==id[IdUpdate]) { keyPressEvent( new QKeyEvent( QEvent::KeyPress, Qt::Key_F2, 0, Qt::NoButton)); } else if(r==id[IdDelete]) { Q3DataTable::deleteCurrent(); } } if ( containerType() == "wJournal" ) { //id = currentRecord()->value(0).toLongLong(); enum { IdInsert=0, IdUpdate, IdDelete, IdView, IdRefresh }; QPointer<Q3PopupMenu> popup = new Q3PopupMenu( this ); int id[ 5 ]; id[ IdInsert ] = popup->insertItem( tr( "New" ) ); id[ IdUpdate ] = popup->insertItem( tr( "Edit" ) ); id[ IdDelete ] = popup->insertItem( tr( "Delete" ) ); id[ IdView ] = popup->insertItem( tr( "View" ) ); id[ IdRefresh ] = popup->insertItem( tr( "Refresh" ) ); int r = popup->exec( e->globalPos() ); delete (Q3PopupMenu*) popup; if(r==id[IdInsert]) emit(insertRequest()); else if(r==id[IdUpdate]) emit(updateRequest()); else if(r==id[IdDelete]) emit(deleteRequest()); else if(r==id[IdView]) emit(viewRequest()); if(r==id[IdRefresh]) { //recalculate(); refresh(); } } e->accept(); }
ZoneViewlet::ZoneViewlet(QMainWindow *mainWindow, QObject *parent): QObject(parent) { // Initialize zones menu and associated actions zonesMenu = synthclone::getChild<QMenu>(mainWindow, "zonesMenu"); applyEffectsAction = synthclone::getChild<QAction> (mainWindow, "applyEffectsZonesAction"); connect(applyEffectsAction, SIGNAL(triggered()), SIGNAL(applyEffectsRequest())); buildTargetsAction = synthclone::getChild<QAction> (mainWindow, "buildTargetsAction"); connect(buildTargetsAction, SIGNAL(triggered()), SIGNAL(buildTargetsRequest())); clearEffectJobsAction = synthclone::getChild<QAction> (mainWindow, "clearEffectJobsAction"); connect(clearEffectJobsAction, SIGNAL(triggered()), SIGNAL(clearEffectJobsRequest())); clearSamplerJobsAction = synthclone::getChild<QAction> (mainWindow, "clearSamplerJobsAction"); connect(clearSamplerJobsAction, SIGNAL(triggered()), SIGNAL(clearSamplerJobsRequest())); clearSamplerJobsButton = synthclone::getChild<QPushButton> (mainWindow, "clearSamplerJobsButton"); connect(clearSamplerJobsButton, SIGNAL(clicked()), SIGNAL(clearSamplerJobsRequest())); clearSelectionAction = synthclone::getChild<QAction> (mainWindow, "clearZonesSelectionAction"); connect(clearSelectionAction, SIGNAL(triggered()), SIGNAL(clearSelectionRequest())); copyAction = synthclone::getChild<QAction>(mainWindow, "copyZonesAction"); connect(copyAction, SIGNAL(triggered()), SIGNAL(copyRequest())); cutAction = synthclone::getChild<QAction>(mainWindow, "cutZonesAction"); connect(cutAction, SIGNAL(triggered()), SIGNAL(cutRequest())); deleteAction = synthclone::getChild<QAction> (mainWindow, "deleteZonesAction"); connect(deleteAction, SIGNAL(triggered()), SIGNAL(deleteRequest())); insertAction = synthclone::getChild<QAction> (mainWindow, "insertZoneAction"); connect(insertAction, SIGNAL(triggered()), SIGNAL(insertRequest())); invertSelectionAction = synthclone::getChild<QAction> (mainWindow, "invertZoneSelectionAction"); connect(invertSelectionAction, SIGNAL(triggered()), SIGNAL(invertSelectionRequest())); pasteAction = synthclone::getChild<QAction>(mainWindow, "pasteZonesAction"); connect(pasteAction, SIGNAL(triggered()), SIGNAL(pasteRequest())); playDrySampleAction = synthclone::getChild<QAction> (mainWindow, "playDrySampleZonesAction"); connect(playDrySampleAction, SIGNAL(triggered()), SIGNAL(playDrySampleRequest())); playWetSampleAction = synthclone::getChild<QAction>(mainWindow, "playWetSampleZonesAction"); connect(playWetSampleAction, SIGNAL(triggered()), SIGNAL(playWetSampleRequest())); removeEffectJobAction = synthclone::getChild<QAction>(mainWindow, "removeEffectJobZonesAction"); connect(removeEffectJobAction, SIGNAL(triggered()), SIGNAL(removeEffectJobRequest())); removeSamplerJobAction = synthclone::getChild<QAction> (mainWindow, "removeSamplerJobZonesAction"); connect(removeSamplerJobAction, SIGNAL(triggered()), SIGNAL(removeSamplerJobRequest())); sampleAction = synthclone::getChild<QAction> (mainWindow, "getSampleZonesAction"); connect(sampleAction, SIGNAL(triggered()), SIGNAL(sampleRequest())); selectAllAction = synthclone::getChild<QAction> (mainWindow, "selectAllZonesAction"); connect(selectAllAction, SIGNAL(triggered()), SIGNAL(selectAllRequest())); initializeColumnShowAction(mainWindow, ZONETABLECOLUMN_AFTERTOUCH, "aftertouchColumnShowAction"); initializeColumnShowAction(mainWindow, ZONETABLECOLUMN_CHANNEL, "channelColumnShowAction"); initializeColumnShowAction(mainWindow, ZONETABLECOLUMN_CHANNEL_PRESSURE, "channelPressureColumnShowAction"); initializeColumnShowAction(mainWindow, ZONETABLECOLUMN_DRY_SAMPLE, "drySampleColumnShowAction"); initializeColumnShowAction(mainWindow, ZONETABLECOLUMN_NOTE, "noteColumnShowAction"); initializeColumnShowAction(mainWindow, ZONETABLECOLUMN_RELEASE_TIME, "releaseTimeColumnShowAction"); initializeColumnShowAction(mainWindow, ZONETABLECOLUMN_SAMPLE_TIME, "sampleTimeColumnShowAction"); initializeColumnShowAction(mainWindow, ZONETABLECOLUMN_STATUS, "statusColumnShowAction"); initializeColumnShowAction(mainWindow, ZONETABLECOLUMN_VELOCITY, "velocityColumnShowAction"); initializeColumnShowAction(mainWindow, ZONETABLECOLUMN_WET_SAMPLE, "wetSampleColumnShowAction"); initializeControlColumnShowActions("controlColumnsMenu1", 0, 0x10); initializeControlColumnShowActions("controlColumnsMenu2", 0x10, 0x20); initializeControlColumnShowActions("controlColumnsMenu3", 0x20, 0x30); initializeControlColumnShowActions("controlColumnsMenu4", 0x30, 0x40); initializeControlColumnShowActions("controlColumnsMenu5", 0x40, 0x50); initializeControlColumnShowActions("controlColumnsMenu6", 0x50, 0x60); initializeControlColumnShowActions("controlColumnsMenu7", 0x60, 0x70); initializeControlColumnShowActions("controlColumnsMenu8", 0x70, 0x80); menuViewlet = new MenuViewlet(zonesMenu); // Setup zones table view connect(&tableDelegate, SIGNAL(aftertouchChangeRequest(int, synthclone::MIDIData)), SIGNAL(aftertouchChangeRequest(int, synthclone::MIDIData))); connect(&tableDelegate, SIGNAL(channelChangeRequest(int, synthclone::MIDIData)), SIGNAL(channelChangeRequest(int, synthclone::MIDIData))); connect(&tableDelegate, SIGNAL(channelPressureChangeRequest(int, synthclone::MIDIData)), SIGNAL(channelPressureChangeRequest(int, synthclone::MIDIData))); connect(&tableDelegate, SIGNAL(controlValueChangeRequest(int, synthclone::MIDIData, synthclone::MIDIData)), SIGNAL(controlValueChangeRequest(int, synthclone::MIDIData, synthclone::MIDIData))); connect(&tableDelegate, SIGNAL(noteChangeRequest(int, synthclone::MIDIData)), SIGNAL(noteChangeRequest(int, synthclone::MIDIData))); connect(&tableDelegate, SIGNAL(releaseTimeChangeRequest(int, synthclone::SampleTime)), SIGNAL(releaseTimeChangeRequest(int, synthclone::SampleTime))); connect(&tableDelegate, SIGNAL(sampleTimeChangeRequest(int, synthclone::SampleTime)), SIGNAL(sampleTimeChangeRequest(int, synthclone::SampleTime))); connect(&tableDelegate, SIGNAL(velocityChangeRequest(int, synthclone::MIDIData)), SIGNAL(velocityChangeRequest(int, synthclone::MIDIData))); itemPrototype = new StandardItem(); connect(&tableModel, SIGNAL(sortRequest(int, bool)), SLOT(handleSortRequest(int, bool))); tableModel.setColumnCount(ZONETABLECOLUMN_BASE_TOTAL); tableModel.setRowCount(0); tableModel.setItemPrototype(itemPrototype); tableModel.setHeaderData(ZONETABLECOLUMN_AFTERTOUCH, Qt::Horizontal, tr("Aftertouch"), Qt::DisplayRole); tableModel.setHeaderData(ZONETABLECOLUMN_CHANNEL, Qt::Horizontal, tr("Channel"), Qt::DisplayRole); tableModel.setHeaderData(ZONETABLECOLUMN_CHANNEL_PRESSURE, Qt::Horizontal, tr("Channel Pressure"), Qt::DisplayRole); tableModel.setHeaderData(ZONETABLECOLUMN_DRY_SAMPLE, Qt::Horizontal, tr("Dry Sample"), Qt::DisplayRole); tableModel.setHeaderData(ZONETABLECOLUMN_NOTE, Qt::Horizontal, tr("Note"), Qt::DisplayRole); tableModel.setHeaderData(ZONETABLECOLUMN_RELEASE_TIME, Qt::Horizontal, tr("Release Time"), Qt::DisplayRole); tableModel.setHeaderData(ZONETABLECOLUMN_SAMPLE_TIME, Qt::Horizontal, tr("Sample Time"), Qt::DisplayRole); tableModel.setHeaderData(ZONETABLECOLUMN_STATUS, Qt::Horizontal, tr("Status"), Qt::DisplayRole); tableModel.setHeaderData(ZONETABLECOLUMN_VELOCITY, Qt::Horizontal, tr("Velocity"), Qt::DisplayRole); tableModel.setHeaderData(ZONETABLECOLUMN_WET_SAMPLE, Qt::Horizontal, tr("Wet Sample"), Qt::DisplayRole); for (synthclone::MIDIData i = 0; i < 0x80; i++) { int column = ZONETABLECOLUMN_CONTROL_0 + i; tableModel.setHeaderData(column, Qt::Horizontal, synthclone::getMIDIControlString(i), Qt::DisplayRole); } tableView = synthclone::getChild<QTableView>(mainWindow, "zoneTableView"); tableView->installEventFilter(&contextMenuEventFilter); tableView->setItemDelegate(&tableDelegate); tableView->setModel(&tableModel); connect(tableView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), SLOT(handleSelectionChange(QItemSelection, QItemSelection))); connect(&contextMenuEventFilter, SIGNAL(contextMenuRequest(int, int)), SLOT(handleContextMenuRequest(int, int))); emitZoneSelectRequest = true; }
void thrdMessage(LPVOID lpvThreadParam) { SOCKET connectSocket = ((LPSocket) lpvThreadParam)->Socket; char inbuffer[250]; CString message1; char strSender[10]; char strClock[100]; char message[100]; int iSender; int iClock; long i; long chars_read; CString outbuffer; char tempclock[100]; chars_read = recv(connectSocket, inbuffer, 250, 0); inbuffer[chars_read] = 0; //Parse Message message1.Format("%s", inbuffer); if (message1.Find(":", 0) != -1) { strcpy(message,strtok(inbuffer, ":")); strcpy(strSender,strtok(NULL, ":")); strcpy(strClock,strtok(NULL, ":")); iSender = atoi(strSender); iClock = atoi(strClock); if (strcmp(message, "REQUEST") == 0) { WaitForSingleObject(sRequest, INFINITE); WaitForSingleObject(sReply, INFINITE); WaitForSingleObject(sClock, INFINITE); LogEvent("Message Received -- %s from %d", inbuffer, iSender); if (myclock < iClock) { myclock = iClock + 1; } else { myclock++; } //outbuffer = "REPLY:"; //outbuffer += ltoa(gProcessID,tempclock, 10); //outbuffer += ":"; //outbuffer += ltoa(myclock, tempclock, 10); //sendMessage(outbuffer, iSender); //LogEvent("Reply Sent immediately to Request for %d", iSender); insertRequest(iSender, iClock); LogEvent("Request Queued"); ReleaseSemaphore(sClock, 1, &i); ReleaseSemaphore(sReply, 1, &i); ReleaseSemaphore(sRequest, 1, &i); } else if (strcmp(message, "GO") == 0) { startThreads(); } else if (strcmp(message, "REPLY") == 0) { WaitForSingleObject(sReply, INFINITE); WaitForSingleObject(sClock, INFINITE); LogEvent("Message Received -- %s from %d", inbuffer, iSender); ReplyQueue[iSender-1] = true; if (myclock < iClock) myclock = iClock + 1; else myclock++; ReleaseSemaphore(sClock, 1, &i); ReleaseSemaphore(sReply, 1, &i); } else if (strcmp(message, "ALIVE") == 0) { LogEvent("Message Received -- %s from %d", inbuffer, iSender); WaitForSingleObject(sAlive, INFINITE); AliveQueue[iSender-1] = true; ReleaseSemaphore(sAlive, 1, &i); } } else { LogEvent("Invalid Message"); } //Clean-up closesocket(connectSocket); ExitThread(0); }