Ejemplo n.º 1
0
  void AsyncCraqGet::get(const CraqDataSetGet& dataToGet, OSegLookupTraceToken* traceToken)
  {
//    Duration beginGetEnqueueManager  = Time::local() - Time::epoch();
//    traceToken->getManagerEnqueueBegin =
//    beginGetEnqueueManager.toMicroseconds();

      traceToken->stamp(OSegLookupTraceToken::OSEG_TRACE_GET_MANAGER_ENQUEUE_BEGIN);

    CraqDataSetGet* cdQuery = new CraqDataSetGet(dataToGet.dataKey,dataToGet.dataKeyValue,dataToGet.trackMessage,CraqDataSetGet::GET);
    QueueValue* qValue = new QueueValue;
    qValue->cdQuery = cdQuery;
    qValue->traceToken = traceToken;
    pushQueue(qValue);

    // Duration endGetEnqueueManager = Time::local() - Time::epoch();
    // traceToken->getManagerEnqueueEnd = endGetEnqueueManager.toMicroseconds();
    traceToken->stamp(OSegLookupTraceToken::OSEG_TRACE_GET_MANAGER_ENQUEUE_END);
    
    int numTries = 0;
    while((mQueue.size()!= 0) && (numTries < CRAQ_MAX_PUSH_GET))
    {
      ++numTries;
      int rand_connection = rand() % STREAM_CRAQ_NUM_CONNECTIONS_GET;
      checkConnections(rand_connection);
    }
  }
Ejemplo n.º 2
0
void Call::acceptLocal() {
	socketLocal = serverLocal->nextPendingConnection();
	serverLocal->close();
	// we don't delete the server, since it contains the socket.
	// we could reparent, but that automatic stuff of QT is great
	connect(socketLocal, SIGNAL(readyRead()), this, SLOT(readLocal()));
	connect(socketLocal, SIGNAL(disconnected()), this, SLOT(checkConnections()));
}
Ejemplo n.º 3
0
void AsyncCraqGet::readyStateChanged(int s) {
    mReadyConnections.push_back(s);
    while (checkConnections(s)) {
        if (mQueue.empty()) {
            break;
        }
    }
}
Ejemplo n.º 4
0
void Dispatcher::handleError() {
    if (errno == EINTR) {
	return;
    }

    if (errno == EBADF) {
	checkConnections();
	return;
    }

    perror("Dispatcher: select");
    exit(1);
}
Ejemplo n.º 5
0
Pipe::~Pipe() {
    checkConnections();

    auto &allPipes = Atomos::getInstance().allPipes;
    assert (allPipes.find(this) != allPipes.end());  // we should be in the set of allPipes
    allPipes.erase(this);

    A.volume->release(A.connectionIndex);
    B.volume->release(B.connectionIndex);

    // make sure the volumes have done their job
    assert (A.volume == nullptr);
    assert (B.volume == nullptr);
}
Ejemplo n.º 6
0
void AsyncCraqGet::pushQueue(QueueValue*qv) {
    mQueue.push(qv);
    while (!mReadyConnections.empty()) {
        unsigned int rnd=rand()%mReadyConnections.size();
        if (checkConnections(mReadyConnections[rnd])) {
            if (mQueue.empty()) {
                break;
            }
        }else {
            mReadyConnections[rnd]=mReadyConnections.back();
            mReadyConnections.pop_back();
        }
    }
}
Ejemplo n.º 7
0
void HttpServer::process()
{
        if(!this->listenSocket.bind(1998)){
            cerr << "Failed to bind server port 1998." << endl;
        }

	this->listenSocket.listen();
	
	while(!this->closed){
		HttpSocket* sock = this->listenSocket.accept();
		if(sock == NULL)
			continue;
		
		HttpConnection* conn = new HttpConnection(sock);
		conn->startThread();
		
		this->connections.push_back(conn);
		checkConnections();
	}
	
	
	checkConnections();
    cout << "httpserver ends." << endl;
}
Ejemplo n.º 8
0
void Listener::clientDropped()
{
    QLocalSocket *socket = qobject_cast<QLocalSocket *>(sender());
    if (!socket) {
        return;
    }

    Console::main()->log("Dropping connection...");
    QMutableVectorIterator<Client> it(m_connections);
    while (it.hasNext()) {
        const Client &client = it.next();
        if (client.socket == socket) {
            Console::main()->log(QString("    dropped... %1").arg(client.name));
            it.remove();
            break;
        }
    }

    checkConnections();
}
Ejemplo n.º 9
0
bool Dispatcher::handleError() {
    switch (errno) {
    case EBADF:
	checkConnections();
	break;
    case EINTR:
	if (_cqueue->isReady()) {
	    return true;
	}
	break;
#if defined(CYGWIN)
    case 0:
	break;
#endif
    default:
	printf("errno=%d\n", errno);
	exit(1);
	/*NOTREACHED*/
    }
    return false;	// retry select;
}
Ejemplo n.º 10
0
Listener::Listener(const QString &resource, QObject *parent)
    : QObject(parent),
      m_server(new QLocalServer(this)),
      m_revision(0)
{
    connect(m_server, &QLocalServer::newConnection,
             this, &Listener::acceptConnection);
    Console::main()->log(QString("Trying to open %1").arg(resource));
    if (!m_server->listen(resource)) {
        // FIXME: multiple starts need to be handled here
        m_server->removeServer(resource);
        if (!m_server->listen(resource)) {
            Console::main()->log("Utter failure to start server");
            exit(-1);
        }
    }

    if (m_server->isListening()) {
        Console::main()->log(QString("Listening on %1").arg(m_server->serverName()));
    }

    QTimer::singleShot(2000, this, SLOT(checkConnections()));
}
Ejemplo n.º 11
0
void Call::acceptRemote() {
	socketRemote = serverRemote->nextPendingConnection();
	serverRemote->close();
	connect(socketRemote, SIGNAL(readyRead()), this, SLOT(readRemote()));
	connect(socketRemote, SIGNAL(disconnected()), this, SLOT(checkConnections()));
}
Ejemplo n.º 12
0
void Pipe::swapMolecules() {
    checkConnections();
    A.volume->getSlot(A.connectionIndex).swap(
        B.volume->getSlot(B.connectionIndex)
    );
}
Ejemplo n.º 13
0
// Set machine
void Reflector::setMachine(Machine const& machine)
{
	machine_ = &machine;
	checkConnections();
}