void AsyncServerSocket::dispatchError(const char *msgstr, int errnoValue) { uint32_t startingIndex = callbackIndex_; CallbackInfo *info = nextCallback(); // Create a message to send over the notification queue QueueMessage msg; msg.type = MessageType::MSG_ERROR; msg.err = errnoValue; msg.msg = std::move(msgstr); while (true) { // Short circuit if the callback is in the primary EventBase thread if (info->eventBase == nullptr) { std::runtime_error ex( std::string(msgstr) + folly::to<std::string>(errnoValue)); info->callback->acceptError(ex); return; } if (info->consumer->getQueue()->tryPutMessageNoThrow(std::move(msg))) { return; } // Fall through and try another callback if (callbackIndex_ == startingIndex) { // The notification queues for all of the callbacks were full. // We can't really do anything at this point. LOG(ERROR) << "failed to dispatch accept error: all accept callback " "queues are full: error msg: " << msg.msg.c_str() << errnoValue; return; } info = nextCallback(); } }
void AsyncServerSocket::dispatchSocket(int socket, SocketAddress&& address) { uint32_t startingIndex = callbackIndex_; // Short circuit if the callback is in the primary EventBase thread CallbackInfo *info = nextCallback(); if (info->eventBase == nullptr) { info->callback->connectionAccepted(socket, address); return; } // Create a message to send over the notification queue QueueMessage msg; msg.type = MessageType::MSG_NEW_CONN; msg.address = std::move(address); msg.fd = socket; // Loop until we find a free queue to write to while (true) { if (info->consumer->getQueue()->tryPutMessageNoThrow(std::move(msg))) { // Success! return. return; } // We couldn't add to queue. Fall through to below ++numDroppedConnections_; if (acceptRateAdjustSpeed_ > 0) { // aggressively decrease accept rate when in trouble static const double kAcceptRateDecreaseSpeed = 0.1; acceptRate_ *= 1 - kAcceptRateDecreaseSpeed; } if (callbackIndex_ == startingIndex) { // The notification queue was full // We can't really do anything at this point other than close the socket. // // This should only happen if a user's service is behaving extremely // badly and none of the EventBase threads are looping fast enough to // process the incoming connections. If the service is overloaded, it // should use pauseAccepting() to temporarily back off accepting new // connections, before they reach the point where their threads can't // even accept new messages. LOG(ERROR) << "failed to dispatch newly accepted socket:" << " all accept callback queues are full"; closeNoInt(socket); return; } info = nextCallback(); } }
bool ChallengeEndGUI::MouseDown(sf::Vector2f mouse) { if(hide) return false; GUI::MouseDown(mouse); if(selected >= (int) proprieties->list.size()) return false; if(selected < 0) return false; if(selected == 0) { Hide(); retryCallback(); } else if(selected == 1) { Hide(); nextCallback(); } else if(selected == 2) { Hide(); backCallback(); } return true; }
// remove void StressTest1::removeMe(CCNode* node) { m_pParent->removeChild(node, true); nextCallback(this); }
// remove void StressTest1::removeMe(Node* node) { getParent()->removeChild(node, true); nextCallback(this); }
void CrashTest::removeThis() { _parent->removeChild(this, true); nextCallback(this); }