Esempio n. 1
0
void ReconnectRouterOp::onDiscoverRouterFinished()
{
    AsyncOp *op = m_op;
    m_op->deleteLater();
    m_op = NULL;

    if (isAborted())
    {
        LOG_DEBUG(QString::fromUtf8("discoverRouter self aborted!"));
        return;
    }

    if (op->isAborted())
    {
        LOG_DEBUG(QString::fromUtf8("discoverRouter op aborted!"));
        return notifyFinished(AbortedError);
    }

    int result = op->result();
    LOG_DEBUG(QString::fromUtf8("discoverRouterSoap result: %1").arg(result));
    if (result != NoError)
    {
        return retry();
    }

    int matchIndex = op->value("matchIndex").toInt();
    LOG_DEBUG(QString::fromUtf8("matchIndex %1").arg(matchIndex));
    if (matchIndex < 0)
    {
        return retry();
    }

    copyValues(op);
    notifyFinished(NoError);
}
Esempio n. 2
0
void IOWorker::retry(RequestHandler* request_handler) {
  Address address;
  if (!request_handler->get_current_host_address(&address)) {
    request_handler->on_error(CASS_ERROR_LIB_NO_HOSTS_AVAILABLE,
                              "All hosts in current policy attempted "
                              "and were either unavailable or failed");
    return;
  }

  PoolMap::iterator it = pools_.find(address);
  if (it != pools_.end() && it->second->is_ready()) {
    const SharedRefPtr<Pool>& pool = it->second;
    Connection* connection = pool->borrow_connection();
    if (connection != NULL) {
      if (!pool->write(connection, request_handler)) {
        request_handler->next_host();
        retry(request_handler);
      }
    } else { // Too busy, or no connections
      pool->wait_for_connection(request_handler);
    }
  } else {
    request_handler->next_host();
    retry(request_handler);
  }
}
Esempio n. 3
0
void Connector::handleWrite() {
  LOG_TRACE << "Connector::handleWrite " << state_;

  if (state_ == kConnecting) {
    int sockfd = removeAndResetChannel();
    int err = getSocketError(sockfd);
    if (err) {
      LOG_WARN << "Connector::handleWrite - SO_ERROR = "
               << err << " " << strerror_tl(err);
      retry(sockfd);
    } else if (isSelfConnect(sockfd)) {
      LOG_WARN << "Connector::handleWrite - Self connect";
      retry(sockfd);
    } else {
      setState(kConnected);
      if (connect_) {
        new_conn_cb_(sockfd);
      } else {
        close(sockfd);
      }
    }
  } else {
    // what happened?
    assert(state_ == kDisconnected);
  }
}
Esempio n. 4
0
void Connector::connect()
{
	// 直接连接
	// 注意:这里是非阻塞connect,一般会立即返回 EINPROGRESS 错误,表示连接操作正在进行中,但是仍未完成,与此同时 TCP 三次握手操作会同时进行
	// 在这之后,我们可以捕获可写事件以及error事件来检查这个链接是否建立成功

	int ret = ::connect(m_sockfd, (struct sockaddr *)&m_peerAddr.getSockAddr(), static_cast<socklen_t>(sizeof m_peerAddr.getSockAddr()));
	// int ret = socktool::connect(m_sockfd, m_peerAddr);

	int err = ((ret == SOCKET_ERROR) ? socktool::geterrno() : 0);
	switch (err) {
	case 0:
		// 连接成功(当客户端和服务器端在同一台主机上的时候,connect会马上返回0)
		LOG_WARN << "warn: socket<" << m_sockfd << "> connect to localhost<" << m_peerAddr.toIpPort() << "> success";
		onConnected();
		break;

#ifdef WIN
	// linux下的EAGAIN和EWOULDBLOCK是同一个值,编译会报错
	case EAGAIN:
#endif
	case EWOULDBLOCK:
	case EINTR:
	case EISCONN:
	case EINPROGRESS:
		// LOG_WARN << "warn: socket <" << m_sockfd << "> starting connecting err = <" << err << ">";

		// 正在连接(tcp三次握手正在进行)
		connecting();
		break;

	case EADDRINUSE:
	case EADDRNOTAVAIL:
	case ECONNREFUSED:
	case ENETUNREACH:
		// 连接失败,重试
		retry();
		break;

	case EACCES:
	case EPERM:
	case EAFNOSUPPORT:
	case EALREADY:
	case EBADF:
	case EFAULT:
	case ENOTSOCK:
		// 连接异常,中断
		retry();
		break;

	default:
		// 发生未识别异常
		// LOG_SOCKET_ERR << "socket<" << m_sockfd << "> connect to peer<" << m_peerAddr.toIpPort() << "> fail, unexpected error = " << err;
		retry();
		break;
	}
}
Esempio n. 5
0
serialPort::serialPort(){

#ifndef WIN32
    file = new QFile();
#endif
    display = false;
    connected = false;
    timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this, SLOT(retry()));

//    portName = "COM1";
    portName = "/dev/ttyS0";

#ifndef WIN32
    file->setFileName(QString::fromStdString(portName));
#endif

//#if defined(Q_OS_LINUX)
//    qDebug() << "yes yes its unix";
//#endif


    this->initializeSettings();

    settingsUI = new SettingsUI();
    settingsUI->setReader(this);
    settingsUI->setupSettings(settings);

}
Esempio n. 6
0
void MSListener::doClose(void)
{
  if (fd()<0)
   {
     removeRetryTimer();
   }
  else
   {
     if (acceptChannel()!=0)
      {
        removeAcceptChannel();
        _deafTod=todsec();
	_listenedTime+=(deafTod()-listenTod());
      }
     delete [] _localName;
     _localName=(struct sockaddr *)(0);
     _localNamelen=0;
     MSChannel::fdsfresh(fd());
#if defined(MS_WINSOCK)
     if (::closesocket(fd())==SOCKET_ERROR)
#else
     if (::close(fd())<0)
#endif
      {
        MSMessageLog::warningMessage("MSListener::close(%s) : warning: close(%d)\n",name().string(),fd());
      }
     _fd=-1;
     _closeTod=todsec();
     _closeCount++;
     _openedTime+=(closeTod()-openTod());
   }
  if (retry()==MSListener::Yes) doRetry();
}
// ---------------------------------------------------------------------------
// Connect()
//
// Connect to CertProvisionInfoServer
// ---------------------------------------------------------------------------
//
TInt RInfoServerClient::Connect()
{
    BTIC_TRACE_PRINT("[CInfoServerClient] Connect --->");

    TInt retry( 2 );

    for (;;)
    {
        TInt status =
            CreateSession( KBTICCertProvInfoServer, TVersion( 0, 0, 0 ), 1 );

        if ( ( status != KErrNotFound ) && ( status != KErrServerTerminated ) )
        {
            return status;
        }

        if ( --retry == 0 )
        {
            return status;
        }

        status = StartServer();

        if ( ( status != KErrNone ) && ( status != KErrAlreadyExists ) )
        {
            return status;
        }
    }
}
Esempio n. 8
0
void batchManager::sRetry()
{
  XSqlQuery retry(_db);
  retry.prepare("SELECT xtbatch.rescheduleBatchItem(batch_id,"
                "       batch_scheduled) AS result"
                "  FROM xtbatch.batch"
                " WHERE (batch_id=:batch_id);");

  QList<XTreeWidgetItem*> list = _batch->selectedItems();
  if (list.size() > 1 &&
      QMessageBox::question(this, tr("Retry all?"),
                            tr("<p>Are you sure you want to retry %1 jobs?"
                               "<p>Note: Scheduled jobs will not be changed;"
                               " use Reschedule to change these.")
                            .arg(list.size()),
                            QMessageBox::Yes | QMessageBox::No,
                            QMessageBox::No) == QMessageBox::No)
    return;

  for (int i = 0; i < list.size(); i++)
  {
    qDebug("%d", list.at(i)->id());
    if (! list.at(i)->text("batch_completed").isEmpty())
    {
      retry.bindValue(":batch_id", list.at(i)->id());
      retry.exec();
    }
  }

  sFillList();
}
Esempio n. 9
0
int				menu_over(t_game *g)
{
	int		key;

	init_display();
	wrefresh(stdscr);
	g->display_choose = 0;
	draw_menu(g);
	while ((key = getch()))
	{
		if (key == 10 && g->display_choose == 0)
		{
			retry(g);
			ft_init_map(g);
			return (endwin(), 1);
		}
		if (key == 10 && g->display_choose == 1)
			menu_hightscores(g);
		if (key == 10 && g->display_choose == 2)
			return (endwin(), 0);
		func_choose(g, key);
		draw_menu(g);
	}
	return (1);
}
Esempio n. 10
0
void CheckInternetOp::onConnectHostFinished()
{
    AsyncOp *op = m_op;
    m_op->deleteLater();
    m_op = NULL;

    if (isAborted())
    {
        LOG_DEBUG(QString::fromUtf8("connectHost self aborted!"));
        return;
    }

    if (op->isAborted())
    {
        LOG_DEBUG(QString::fromUtf8("connectHost op aborted!"));
        return notifyFinished(AbortedError);
    }

    int result = op->result();
    LOG_DEBUG(QString::fromUtf8("connectHost result: %1").arg(result));
    if (result != NoError)
    {
        return retry();
    }

    notifyFinished(NoError);
}
Esempio n. 11
0
void ReconnectRouterOp::onConnectProfileFinished()
{
    AsyncOp *op = m_op;
    m_op->deleteLater();
    m_op = NULL;

    if (isAborted())
    {
        LOG_DEBUG(QString::fromUtf8("connectProfile self aborted!"));
        return;
    }

    if (op->isAborted())
    {
        LOG_DEBUG(QString::fromUtf8("connectProfile op aborted!"));
        return notifyFinished(AbortedError);
    }

    int result = op->result();
    LOG_DEBUG(QString::fromUtf8("connectWlanProfile %1 result: %1").arg(m_wifiName).arg(result));
    if (result == WlanProfileNotFound )
    {
        LOG_DEBUG(QString::fromUtf8("recreate profile?"));
        notifyFinished(WlanProfileNotFound);
    }
    if (result != NoError)
    {
        return retry();
    }

    discoverRouter();
}
Esempio n. 12
0
void RequestHandler::handle_retry_decision(ResponseMessage* response,
                                           const RetryPolicy::RetryDecision& decision) {
  ErrorResponse* error =
      static_cast<ErrorResponse*>(response->response_body().get());

  switch(decision.type()) {
    case RetryPolicy::RetryDecision::RETURN_ERROR:
      set_error_with_error_response(response->response_body(),
                                    static_cast<CassError>(CASS_ERROR(
                                                             CASS_ERROR_SOURCE_SERVER, error->code())),
                                    error->message().to_string());
      break;

    case RetryPolicy::RetryDecision::RETRY:
      set_consistency(decision.retry_consistency());
      if (!decision.retry_current_host()) {
        next_host();
      }
      if (state() == REQUEST_STATE_DONE) {
        retry();
      } else {
        set_state(REQUEST_STATE_RETRY_WRITE_OUTSTANDING);
      }
      break;

    case RetryPolicy::RetryDecision::IGNORE:
      set_response(SharedRefPtr<Response>(new ResultResponse()));
      break;
  }
  num_retries_++;
}
Esempio n. 13
0
void ForwardingCatalogManager::writeConfigServerDirect(const BatchedCommandRequest& request,
                                                       BatchedCommandResponse* response) {
    retry([&] {
        BatchedCommandResponse theResponse;
        _actual->writeConfigServerDirect(request, &theResponse);
        theResponse.cloneTo(response);
    });
}
Esempio n. 14
0
void Connector::stopInLoop() {
  loop_->assertInLoopThread();
  if (state_ == kConnecting) {
    setState(kDisconnected);
    int sockfd = removeAndResetChannel();
    retry(sockfd);
  }
}
Esempio n. 15
0
Status ForwardingCatalogManager::getChunks(const BSONObj& query,
                                           const BSONObj& sort,
                                           boost::optional<int> limit,
                                           std::vector<ChunkType>* chunks,
                                           repl::OpTime* opTime) {
    invariant(chunks->empty());
    return retry([&] { return _actual->getChunks(query, sort, limit, chunks, opTime); });
}
Esempio n. 16
0
void Connector::handleError() {
  LOG_ERROR << "Connector::handleError state=" << state_;
  if (state_ == kConnecting) {
    int sockfd = removeAndResetChannel();
    int err = getSocketError(sockfd);
    LOG_TRACE << "SO_ERROR = " << err << " " << strerror_tl(err);
    retry(sockfd);
  }
}
Esempio n. 17
0
void RequestHandler::on_error(CassError code, const std::string& message) {
  if (code == CASS_ERROR_LIB_WRITE_ERROR ||
      code == CASS_ERROR_LIB_UNABLE_TO_SET_KEYSPACE) {
    next_host();
    retry();
    return_connection();
  } else {
    set_error(code, message);
  }
}
Esempio n. 18
0
bool ForwardingCatalogManager::runUserManagementReadCommand(const std::string& dbname,
                                                            const BSONObj& cmdObj,
                                                            BSONObjBuilder* result) {
    return retry([&] {
        BSONObjBuilder builder;
        const bool success = _actual->runUserManagementReadCommand(dbname, cmdObj, &builder);
        result->appendElements(builder.done());
        return success;
    });
}
Esempio n. 19
0
Status ForwardingCatalogManager::shardCollection(OperationContext* txn,
                                                 const std::string& ns,
                                                 const ShardKeyPattern& fieldsAndOrder,
                                                 bool unique,
                                                 const std::vector<BSONObj>& initPoints,
                                                 const std::set<ShardId>& initShardsIds) {
    return retry([&] {
        return _actual->shardCollection(txn, ns, fieldsAndOrder, unique, initPoints, initShardsIds);
    });
}
Esempio n. 20
0
TInt RSecMgrSession::Connect()
    {
    RTSecMgrTraceFunction("RSecMgrSession::Connect()") ;
    TInt err(KErrNone);
        // Try to create a Server session
    err = CreateSession ( KSecServerProcessName, Version (),
            KDefaultMessageSlots);

    if ( err != KErrNotFound && err != KErrServerTerminated)
        {
        // KErrNone or unrecoverable error
        if ( err != KErrNone)
            {
#ifdef _DEBUG
            RDebug::Print(KServerStartFailed);
#endif
            }
        
        }
    else
        {
        // Return code was KErrNotFound or KErrServerTerminated.
        // Try to start a new security manager server instance
        TInt retry(KSecSrvClientTryCount);
        while(retry > 0)
            {
            err = StartSecManagerServer ();
            if ( err != KErrNone && err != KErrAlreadyExists)
                {
                // Unrecoverable error
                #ifdef _DEBUG
                            RDebug::Print(KServerStartFailed);
                #endif
                retry = 0;
                }
            else
                {
                err = CreateSession ( KSecServerProcessName, Version (),
                                                KDefaultMessageSlots);
                if(err != KErrNotFound && err != KErrServerTerminated)
                    {
                    if ( err != KErrNone)
                                {
                    #ifdef _DEBUG
                                RDebug::Print(KServerStartFailed);
                    #endif
                                }
                    retry = 0;
                    }
                }
            retry--;
            }
        }       
    return (err);
    }
void HTTPCURLRequest::finish(ResponseStatus status) {
    if (status == ResponseStatus::TemporaryError && attempts < maxAttempts) {
        strategy = ExponentialBackoff;
        return retry((1 << (attempts - 1)) * 1000);
    } else if (status == ResponseStatus::ConnectionError && attempts < maxAttempts) {
        // By default, we will retry every 30 seconds (network change notification will
        // preempt the timeout).
        strategy = PreemptImmediately;
        return retry(30000);
    }

    // Actually return the response.
    if (status == ResponseStatus::NotModified) {
        notify(std::move(response), FileCache::Hint::Refresh);
    } else {
        notify(std::move(response), FileCache::Hint::Full);
    }

    delete this;
}
void LLRegionPresenceVerifier::VerifiedDestinationResponder::error(U32 status, const std::string& reason)
{
	if(mRetryCount > 0)
	{
		retry();
	}
	else
	{
		llwarns << "Failed to contact simulator for verification. Region: " << mUri << llendl;
		mSharedData->onRegionVerificationFailed();
	}
}
Esempio n. 23
0
void O2Requestor::onRefreshFinished(QNetworkReply::NetworkError error) {
    if (status_ != Requesting) {
        qWarning() << "O2Requestor::onRefreshFinished: No pending request";
        return;
    }
    if (QNetworkReply::NoError == error) {
        QTimer::singleShot(100, this, SLOT(retry()));
    } else {
        error_ = error;
        QTimer::singleShot(10, this, SLOT(finish()));
    }
}
Esempio n. 24
0
bool FileServerTask::maybeRetry()
{
    if (canceled_ || !retryEnabled()) {
        return false;
    }
    if (retry_count_ >= kFileServerTaskMaxRetry) {
        return false;
    } else {
        retry_count_++;
        qDebug("[file server task] schedule file server task retry for the %d time\n", retry_count_);
        QTimer::singleShot(kFileServerTaskRetryIntervalSecs * 1000, this, SLOT(retry()));
        return true;
    }
}
Esempio n. 25
0
void RequestHandler::on_error_unprepared(ErrorResponse* error) {
  ScopedRefPtr<PrepareHandler> prepare_handler(new PrepareHandler(this));
  if (prepare_handler->init(error->prepared_id().to_string())) {
    if (!connection_->write(prepare_handler.get())) {
      // Try to prepare on the same host but on a different connection
      retry();
    }
  } else {
    connection_->defunct();
    set_error(CASS_ERROR_LIB_UNEXPECTED_RESPONSE,
              "Received unprepared error for invalid "
              "request type or invalid prepared id");
  }
}
Esempio n. 26
0
msl::msl(QWidget *parent) :
        QWidget(parent),
        serialConnection("","","",""/*Manufacturer String*/,""/*Product String*/)
{

	ui.setupUi(this);
	//Create QColorDialog
	this->colorDialog = new QColorDialog(this);
	this->colorDialog->setWindowFlags(Qt::Widget);

	//Remove buttons and dialog
	this->colorDialog->setOptions(
			QColorDialog::DontUseNativeDialog | QColorDialog::NoButtons);
	//SetColor
	this->colorDialog->setCurrentColor(QColor(Qt::black));
	this->ui.LayoutForColorSelector->addWidget(colorDialog);

	//Connect the colorChanged signal
	connect(this->colorDialog, SIGNAL(currentColorChanged(QColor)), this,
			SLOT(colorChanged(QColor)));

	//Hide the EEProm settings-box
	this->ui.groupBox_EEProm->hide();

	//Disable the GUI as long as there is no connection to the serial
	this->setDisabled(1);

	//Connect the signals
	connect(&this->serialConnection,
                        SIGNAL(serialAbortedConnect(int)), this,
                        SLOT(serialConnectionAbort(int)));

	connect(&this->serialConnection, SIGNAL(waitingForRetry()), this,
			SLOT(serialWaitingForRetry()));
	connect(&this->serialConnection, SIGNAL(serialConnected()), this,
			SLOT(serialConnected()));
	connect(this, SIGNAL(retry()), &this->serialConnection,
			SLOT(retryConnect()));

	connect(this, SIGNAL(sendArray(QByteArray)),&this->serialConnection,SLOT(sendArray(QByteArray)));

	//Start serial connection thread
	serialConnection.start();
	serialConnection.setStopBits(qUSBSerial::StopBits_2);

	//Connect to Microscope Light
	serialConnection.serialConnect();

}
Esempio n. 27
0
// -----------------------------------------------------------------------------
// RPsmServer::Connect
// Connects to PSM server
// -----------------------------------------------------------------------------
//
TInt RPsmServer::Connect()
    {
    COMPONENT_TRACE( ( _L( "PSM Client - RPsmServer::Connect()" ) ) );

    // Try this twice
    TInt retry( KPsmClientTryCount );
    TInt err( KErrNone );

    while (retry > 0)
        {
        // Try to create a PSM Server session
        err = CreateSession( KPsmProcessName, 
                             ServerVersion(), 
                             KPsmServerDefaultAsyncSlots );

        COMPONENT_TRACE( ( _L( "PSM Client - RPsmServer::Connect - CreateSession returned: %d" ), err ) );        
        
        if ( err != KErrNotFound && err != KErrServerTerminated )
            {
            // KErrNone or unrecoverable error
            if (err != KErrNone)
                {
                ERROR_TRACE( ( _L( "PSM Client - RPsmServer::Connect - ERROR: CreateSession unrecoverable error: %d" ), err ) );
                }
            
            retry = 0;
            }
        else
            {
            // Return code was KErrNotFound or KErrServerTerminated.
            // Try to start a new PSM Server
            err = StartServer();

            COMPONENT_TRACE( ( _L( "PSM Client - RPsmServer::Connect - StartServer returned: %d" ), err ) );        

            if ( err != KErrNone && err != KErrAlreadyExists )
                {
                // Unrecoverable error
                ERROR_TRACE( ( _L( "PSM Client - RPsmServer::Connect - ERROR: StartServer unrecoverable error: %d" ), err ) );
                retry = 0;
                }
            }
                
        retry--;
        }
        
    COMPONENT_TRACE( ( _L( "PSM Client - RPsmServer::Connect - return %d" ), err ) );        
    return err;
    }
Esempio n. 28
0
void msl::serialWaitingForRetry()
{
	this->setDisabled(1);
    QLinuxUSBSerialAutoConnectorGUI retryGUI(this, 10, "Microscope");
	qDebug() << "receivedWatingForRetry";
	int ret = retryGUI.exec();
	if (ret)
	{
		emit retry();
	}
	else
	{
		exit(1);
	}
}
Esempio n. 29
0
void Connector::handleWrite()
{
	// 先检测套接字是否发生异常
	m_errno = socktool::getSocketError(m_sockfd);
	if (m_errno > 0) {
		// 若检测到异常,则重连
		LOG_SOCKET_ERR(m_sockfd, m_errno) << m_pNetReactor->name();
		retry();

		return;
	}

	// 成功建立连接
	onConnected();
}
Esempio n. 30
0
void levelReset() { // Resets level when dead
    g_eGameState = GAME;
    player.bomb = 1;
    uCooldown = 0;
    fight = NORMAL;
    retry();
    cobwebToken = 0;
    timesRetry++;
    soundreset();
    gamesoundToken = 0;
    monsterToken = 1;
    monster1Token = 1;
    Bhealth = 50;
	t_wProjectile = 0;
}