Esempio n. 1
0
void BaseConnection::closeConnection() {
  if (mState != CONNECTED) {
    // Nothing to do here
    LOG(ERROR) << "Connection already closed, hence doing nothing\n";
    return;
  }
  mState = TO_BE_DISCONNECTED;
  internalClose();
}
Esempio n. 2
0
void WriteThread::internalReopen()
{
	ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"["+QString::number(id)+"] start");
	internalClose(false);
	flushBuffer();
	stopIt=false;
	CurentCopiedSize=0;
	if(internalOpen())
		emit reopened();
}
Esempio n. 3
0
void WriteThread::run()
{
        connect(this,SIGNAL(internalStartOpen()),               this,SLOT(internalOpen()),              Qt::QueuedConnection);
        connect(this,SIGNAL(internalStartReopen()),             this,SLOT(internalReopen()),            Qt::QueuedConnection);
        connect(this,SIGNAL(internalStartWrite()),              this,SLOT(internalWrite()),             Qt::QueuedConnection);
        connect(this,SIGNAL(internalStartClose()),              this,SLOT(internalClose()),             Qt::QueuedConnection);
	connect(this,SIGNAL(internalStartEndOfFile()),		this,SLOT(internalEndOfFile()),		Qt::QueuedConnection);
	connect(this,SIGNAL(internalStartFlushAndSeekToZero()), this,SLOT(internalFlushAndSeekToZero()),Qt::QueuedConnection);
	connect(this,SIGNAL(internalStartChecksum()),		this,SLOT(checkSum()),			Qt::QueuedConnection);
	exec();
}
Esempio n. 4
0
void WriteThread::internalReopen()
{
    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,QStringLiteral("[")+QString::number(id)+QStringLiteral("] start"));
    QString tempFile=file.fileName();
    internalClose(false);
    flushBuffer();
    stopIt=false;
    lastGoodPosition=0;
    file.setFileName(tempFile);
    if(internalOpen())
        emit reopened();
}
Esempio n. 5
0
			bool  SocketSession::check(){

				time_t now = time(NULL);
				//检查不活跃期超时(activity)
				if(now - getLastActivity() > getWait()){
					LOG_DEBUG("SocketSession::check => del a session : sid = " << getSessionId() << " userId = " << getUserId());
					LOG_TRACE_ACTION(" sockSessionTimeOut"<<" | "<<getUserId()<<" | "<<getSessionId()<<" | "<<getCAppId()<<" | "<<"000000");
					internalClose();
					return 1;
				} 			
				return 0;
			}
Esempio n. 6
0
void WriteThread::internalReopen()
{
    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"["+std::to_string(id)+"] start");
    std::string tempFile=fileName;
    internalClose(false);
    flushBuffer();
    stopIt=false;
    lastGoodPosition=0;
    fileName=tempFile;
    if(internalOpen())
        emit reopened();
}
Esempio n. 7
0
NS_IMETHODIMP
Connection::Close()
{
  if (!mDBConn)
    return NS_ERROR_NOT_INITIALIZED;

  { // Make sure we have not executed any asynchronous statements.
    MutexAutoLock lockedScope(sharedAsyncExecutionMutex);
    NS_ENSURE_FALSE(mAsyncExecutionThread, NS_ERROR_UNEXPECTED);
  }

  nsresult rv = setClosedState();
  NS_ENSURE_SUCCESS(rv, rv);

  return internalClose();
}
Esempio n. 8
0
void BaseConnection::handleRead(EventLoop::Status status) {
  CHECK(status == EventLoop::READ_EVENT);
  mReadState = READY;
  sp_int32 readStatus = readFromEndPoint(mEndpoint->get_fd());
  if (readStatus >= 0) {
    mReadState = NOTREADY;
  } else {
    mReadState = ERROR;
    mState = TO_BE_DISCONNECTED;
  }

  bool prevValue = mCanCloseConnection;
  mCanCloseConnection = false;
  handleDataRead();
  mCanCloseConnection = prevValue;
  if (mState != CONNECTED) {
    internalClose();
  }
}
Esempio n. 9
0
// Note that we hold the mutex when we come to this function
void BaseConnection::handleWrite(EventLoop::Status status) {
  CHECK_EQ(status, EventLoop::WRITE_EVENT);
  mWriteState = NOTREGISTERED;

  if (mState != CONNECTED) return;

  sp_int32 writeStatus = writeIntoEndPoint(mEndpoint->get_fd());
  if (writeStatus < 0) {
    mWriteState = ERROR;
    mState = TO_BE_DISCONNECTED;
  }
  if (mState == CONNECTED && mWriteState == NOTREGISTERED && stillHaveDataToWrite()) {
    mWriteState = NOTREADY;
    CHECK_EQ(mEventLoop->registerForWrite(mEndpoint->get_fd(), mOnWrite, false), 0);
  }

  bool prevValue = mCanCloseConnection;
  mCanCloseConnection = false;
  handleDataWritten();
  mCanCloseConnection = prevValue;
  if (mState != CONNECTED) {
    internalClose();
  }
}
Esempio n. 10
0
QOggSimplePlayer::~QOggSimplePlayer()
{
    emit internalClose();
}
Esempio n. 11
0
void ReadThread::internalCloseSlot()
{
    internalClose();
}
Esempio n. 12
0
void ReadThread::internalRead()
{
    isInReadLoop=true;
    tryStartRead=false;
    if(stopIt)
    {
        ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"["+QString::number(id)+"] stopIt == true, then quit");
        internalClose();
        return;
    }
#ifdef ULTRACOPIER_PLUGIN_DEBUG
    stat=InodeOperation;
#endif
    int sizeReaden=0;
    if(!file.isOpen())
    {
        ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"["+QString::number(id)+"] is not open!");
        return;
    }
    QByteArray blockArray;
    //numberOfBlockCopied	= 0;
    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"["+QString::number(id)+"] start the copy");
    emit readIsStarted();
#ifdef ULTRACOPIER_PLUGIN_DEBUG
    stat=Idle;
#endif
    if(stopIt)
    {
        ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"["+QString::number(id)+"] stopIt == true, then quit");
        internalClose();
        return;
    }
    do
    {
        //read one block
#ifdef ULTRACOPIER_PLUGIN_DEBUG
        stat=Read;
#endif
        blockArray=file.read(blockSize);
#ifdef ULTRACOPIER_PLUGIN_DEBUG
        stat=Idle;
#endif

        if(file.error()!=QFile::NoError)
        {
            errorString_internal=tr("Unable to read the source file: ")+file.errorString()+" ("+QString::number(file.error())+")";
            ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"["+QString::number(id)+"] "+QString("file.error()!=QFile::NoError: %1, error: %2").arg(QString::number(file.error())).arg(errorString_internal));
            emit error();
            isInReadLoop=false;
            return;
        }
        sizeReaden=blockArray.size();
        if(sizeReaden>0)
        {
#ifdef ULTRACOPIER_PLUGIN_DEBUG
            stat=WaitWritePipe;
#endif
            if(!writeThread->write(blockArray))
            {
                if(!stopIt)
                {
                    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"["+QString::number(id)+"] stopped because the write is stopped: "+QString::number(lastGoodPosition));
                    stopIt=true;
                }
            }

#ifdef ULTRACOPIER_PLUGIN_DEBUG
            stat=Idle;
#endif

            if(stopIt)
                break;

            lastGoodPosition+=blockArray.size();

            //wait for limitation speed if stop not query
            if(multiForBigSpeed>0)
            {
                numberOfBlockCopied++;
                if(numberOfBlockCopied>=multiForBigSpeed)
                {
                    numberOfBlockCopied=0;
                    waitNewClockForSpeed.acquire();
                    if(stopIt)
                        break;
                }
            }
        }
        /*
        if(lastGoodPosition>16*1024)
        {
            ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"["+QString::number(id)+"] "+QString("Test error in reading: %1 (%2)").arg(file.errorString()).arg(file.error()));
            errorString_internal=QString("Test error in reading: %1 (%2)").arg(file.errorString()).arg(file.error());
            emit error();
            isInReadLoop=false;
            return;
        }
        */
    }
    while(sizeReaden>0 && !stopIt);
    if(lastGoodPosition>file.size())
    {
        errorString_internal=tr("File truncated during the read, possible data change");
        ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"["+QString::number(id)+"] "+QString("Source truncated during the read: %1 (%2)").arg(file.errorString()).arg(QString::number(file.error())));
        emit error();
        isInReadLoop=false;
        return;
    }
    isInReadLoop=false;
    if(stopIt)
    {
        if(putInPause)
            emit isInPause();
        stopIt=false;
        return;
    }
    emit readIsStopped();//will product by signal connection writeThread->endIsDetected();
    ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"["+QString::number(id)+"] stop the read");
}
Esempio n. 13
0
void WriteThread::internalCloseSlot()
{
    internalClose();
}
void GeoPackageWriter::close()
{
    log()->get(LogLevel::Debug) << "GeoPackageWriter::close" << std::endl;
    internalClose();
    //dumpStats();
}