void WebServer::handleClient() { WiFiClient client = _server.available(); if (!client) { return; } #ifdef DEBUG DEBUG_OUTPUT.println("New client"); #endif // Wait for data from client to become available uint16_t maxWait = HTTP_MAX_DATA_WAIT; while(client.connected() && !client.available() && maxWait--){ delay(1); } if (!_parseRequest(client)) { return; } _currentClient = client; _handleRequest(); }
void ESP8266WebServer::handleClient() { if (_currentStatus == HC_NONE) { WiFiClient client = _server.available(); if (!client) { return; } #ifdef DEBUG_ESP_HTTP_SERVER DEBUG_OUTPUT.println("New client"); #endif _currentClient = client; _currentStatus = HC_WAIT_READ; _statusChange = millis(); } if (!_currentClient.connected()) { _currentClient = WiFiClient(); _currentStatus = HC_NONE; return; } // Wait for data from client to become available if (_currentStatus == HC_WAIT_READ) { if (!_currentClient.available()) { if (millis() - _statusChange > HTTP_MAX_DATA_WAIT) { _currentClient = WiFiClient(); _currentStatus = HC_NONE; } yield(); return; } if (!_parseRequest(_currentClient)) { _currentClient = WiFiClient(); _currentStatus = HC_NONE; return; } _currentClient.setTimeout(HTTP_MAX_SEND_WAIT); _contentLength = CONTENT_LENGTH_NOT_SET; _handleRequest(); if (!_currentClient.connected()) { _currentClient = WiFiClient(); _currentStatus = HC_NONE; return; } else { _currentStatus = HC_WAIT_CLOSE; _statusChange = millis(); return; } } if (_currentStatus == HC_WAIT_CLOSE) { if (millis() - _statusChange > HTTP_MAX_CLOSE_WAIT) { _currentClient = WiFiClient(); _currentStatus = HC_NONE; } else { yield(); return; } } }
return Status::OK(); } virtual bool run(OperationContext* txn, const std::string& dbname, BSONObj& cmdObj, int options, std::string& errmsg, BSONObjBuilder& result) { RARELY { warning() << "The group command is deprecated. See " "http://dochub.mongodb.org/core/group-command-deprecation."; } GroupRequest groupRequest; Status parseRequestStatus = _parseRequest(dbname, cmdObj, &groupRequest); if (!parseRequestStatus.isOK()) { return appendCommandStatus(result, parseRequestStatus); } AutoGetCollectionForRead ctx(txn, groupRequest.ns); Collection* coll = ctx.getCollection(); auto statusWithPlanExecutor = getExecutorGroup(txn, coll, groupRequest, PlanExecutor::YIELD_AUTO); if (!statusWithPlanExecutor.isOK()) { return appendCommandStatus(result, statusWithPlanExecutor.getStatus()); } unique_ptr<PlanExecutor> planExecutor = std::move(statusWithPlanExecutor.getValue());
void ESP8266WebServer::handleClient() { if (_currentStatus == HC_NONE) { WiFiClient client = _server.available(); if (!client) { return; } #ifdef DEBUG_ESP_HTTP_SERVER DEBUG_OUTPUT.println("New client"); #endif _currentClient = client; _currentStatus = HC_WAIT_READ; _statusChange = millis(); } bool keepCurrentClient = false; bool callYield = false; if (_currentClient.connected()) { switch (_currentStatus) { case HC_NONE: break; case HC_WAIT_READ: // Wait for data from client to become available if (_currentClient.available()) { if (_parseRequest(_currentClient)) { _currentClient.setTimeout(HTTP_MAX_SEND_WAIT); _contentLength = CONTENT_LENGTH_NOT_SET; _handleRequest(); if (_currentClient.connected()) { _currentStatus = HC_WAIT_CLOSE; _statusChange = millis(); keepCurrentClient = true; } } } else { // !_currentClient.available() if (millis() - _statusChange <= HTTP_MAX_DATA_WAIT) { keepCurrentClient = true; } callYield = true; } break; case HC_WAIT_CLOSE: // Wait for client to close the connection if (millis() - _statusChange <= HTTP_MAX_CLOSE_WAIT) { keepCurrentClient = true; callYield = true; } } } if (!keepCurrentClient) { _currentClient = WiFiClient(); _currentStatus = HC_NONE; _currentUpload.reset(); } if (callYield) { yield(); } }