void IDBDatabaseBackend::runIntVersionChangeTransaction(PassRefPtr<IDBCallbacks> prpCallbacks, PassRefPtr<IDBDatabaseCallbacks> prpDatabaseCallbacks, int64_t transactionId, int64_t requestedVersion) { RefPtr<IDBCallbacks> callbacks = prpCallbacks; RefPtr<IDBDatabaseCallbacks> databaseCallbacks = prpDatabaseCallbacks; ASSERT(callbacks); for (DatabaseCallbacksSet::const_iterator it = m_databaseCallbacksSet.begin(); it != m_databaseCallbacksSet.end(); ++it) { // Front end ensures the event is not fired at connections that have closePending set. if (*it != databaseCallbacks) (*it)->onVersionChange(m_metadata.version, requestedVersion, IndexedDB::NullVersion); } // The spec dictates we wait until all the version change events are // delivered and then check m_databaseCallbacks.empty() before proceeding // or firing a blocked event, but instead we should be consistent with how // the old setVersion (incorrectly) did it. // FIXME: Remove the call to onBlocked and instead wait until the frontend // tells us that all the blocked events have been delivered. See // https://bugs.webkit.org/show_bug.cgi?id=71130 if (connectionCount()) callbacks->onBlocked(m_metadata.version); // FIXME: Add test for m_runningVersionChangeTransaction. if (m_runningVersionChangeTransaction || connectionCount()) { m_pendingOpenCalls.append(IDBPendingOpenCall::create(*callbacks, *databaseCallbacks, transactionId, requestedVersion)); return; } Vector<int64_t> objectStoreIds; createTransaction(transactionId, databaseCallbacks, objectStoreIds, IndexedDB::TransactionVersionChange); RefPtr<IDBTransactionBackend> transaction = m_transactions.get(transactionId); transaction->scheduleVersionChangeOperation(transactionId, requestedVersion, callbacks, databaseCallbacks, m_metadata); ASSERT(!m_pendingSecondHalfOpen); m_databaseCallbacksSet.add(databaseCallbacks); }
QWidget *BuddyEditor::widgetAt(const QPoint &pos) const { QWidget *w = ConnectionEdit::widgetAt(pos); while (w != 0 && !m_formWindow->isManaged(w)) w = w->parentWidget(); if (!w) return w; if (state() == Editing) { QLabel *label = qobject_cast<QLabel*>(w); if (label == 0) return 0; const int cnt = connectionCount(); for (int i = 0; i < cnt; ++i) { Connection *con = connection(i); if (con->widget(EndPoint::Source) == w) return 0; } } else { if (!canBeBuddy(w, m_formWindow)) return 0; } return w; }
void IDBDatabaseBackendImpl::deleteDatabase(PassRefPtr<IDBCallbacks> prpCallbacks) { if (m_runningVersionChangeTransaction) { m_pendingDeleteCalls.append(PendingDeleteCall::create(prpCallbacks)); return; } RefPtr<IDBCallbacks> callbacks = prpCallbacks; for (DatabaseCallbacksSet::const_iterator it = m_databaseCallbacksSet.begin(); it != m_databaseCallbacksSet.end(); ++it) { // Front end ensures the event is not fired at connections that have closePending set. (*it)->onVersionChange(NoStringVersion); } // FIXME: Only fire onBlocked if there are open connections after the // VersionChangeEvents are received, not just set up to fire. // https://bugs.webkit.org/show_bug.cgi?id=71130 if (connectionCount()) { m_pendingDeleteCalls.append(PendingDeleteCall::create(callbacks)); callbacks->onBlocked(); return; } ASSERT(m_backingStore); if (!m_backingStore->deleteDatabase(m_metadata.name)) { callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UNKNOWN_ERR, "Internal error.")); return; } m_metadata.version = NoStringVersion; m_metadata.id = InvalidId; m_metadata.intVersion = IDBDatabaseMetadata::NoIntVersion; m_objectStores.clear(); callbacks->onSuccess(); }
DomConnections *SignalSlotEditor::toUi() const { DomConnections *result = new DomConnections; QList<DomConnection*> list; const int count = connectionCount(); for (int i = 0; i < count; ++i) { const SignalSlotConnection *con = static_cast<const SignalSlotConnection*>(connection(i)); Q_ASSERT(con != 0); // If a widget's parent has been removed or moved to a different form, // and the parent was not a managed widget // (a page in a tab widget), we never get a widgetRemoved(). So we filter out // these child widgets here (check QPointer and verify ancestor). // Also, the user might demote a promoted widget or remove a fake // slot in the editor, which causes the connection to become invalid // once he doubleclicks on the method combo. switch (con->isValid(background())) { case SignalSlotConnection::Valid: list.append(con->toUi()); break; case SignalSlotConnection::ObjectDeleted: case SignalSlotConnection::InvalidMethod: case SignalSlotConnection::NotAncestor: break; } } result->setElementConnection(list); return result; }
void PannerNode::pullInputs(ContextRenderLock& r, size_t framesToProcess) { // We override pullInputs(), so we can detect new AudioSourceNodes which have connected to us when new connections are made. // These AudioSourceNodes need to be made aware of our existence in order to handle doppler shift pitch changes. auto ac = r.context(); if (!ac) return; if (m_connectionCount != ac->connectionCount()) { m_connectionCount = ac->connectionCount(); // Recursively go through all nodes connected to us. // notifyAudioSourcesConnectedToNode(r, this); //@tofix dimitri commented out } AudioNode::pullInputs(r, framesToProcess); }
void IDBDatabaseBackend::close(PassRefPtr<IDBDatabaseCallbacks> prpCallbacks) { RefPtr<IDBDatabaseCallbacks> callbacks = prpCallbacks; ASSERT(m_databaseCallbacksSet.contains(callbacks)); m_databaseCallbacksSet.remove(callbacks); if (m_pendingSecondHalfOpen && m_pendingSecondHalfOpen->databaseCallbacks() == callbacks) { m_pendingSecondHalfOpen->callbacks()->onError(IDBDatabaseError::create(IDBDatabaseException::AbortError, "The connection was closed.")); m_pendingSecondHalfOpen.release(); } if (connectionCount() > 1) return; // processPendingCalls allows the inspector to process a pending open call // and call close, reentering IDBDatabaseBackend::close. Then the // backend would be removed both by the inspector closing its connection, and // by the connection that first called close. // To avoid that situation, don't proceed in case of reentrancy. if (m_closingConnection) return; TemporaryChange<bool> closingConnection(m_closingConnection, true); processPendingCalls(); // FIXME: Add a test for the m_pendingOpenCalls cases below. if (!connectionCount() && !m_pendingOpenCalls.size() && !m_pendingDeleteCalls.size()) { TransactionMap transactions(m_transactions); RefPtr<IDBDatabaseError> error = IDBDatabaseError::create(IDBDatabaseException::UnknownError, "Connection is closing."); for (TransactionMap::const_iterator::Values it = transactions.values().begin(), end = transactions.values().end(); it != end; ++it) (*it)->abort(error); ASSERT(m_transactions.isEmpty()); m_serverConnection->close(); // This check should only be false in unit tests. ASSERT(m_factory); if (m_factory) m_factory->removeIDBDatabaseBackend(m_identifier); } }
//*********************************************************************** bool ICACHE_FLASH_ATTR easyMesh::adoptionCalc( meshConnectionType *conn ) { // make the adoption calulation. Figure out how many nodes I am connected to exclusive of this connection. uint16_t mySubCount = connectionCount( conn ); //exclude this connection. uint16_t remoteSubCount = jsonSubConnCount( conn->subConnections ); bool ret = ( mySubCount > remoteSubCount ) ? false : true; debugMsg( GENERAL, "adoptionCalc(): mySubCount=%d remoteSubCount=%d ret = %d\n", mySubCount, remoteSubCount, ret); return ret; }
void IDBDatabaseBackendImpl::close(PassRefPtr<IDBDatabaseCallbacks> prpCallbacks) { RefPtr<IDBDatabaseCallbacks> callbacks = prpCallbacks; ASSERT(m_databaseCallbacksSet.contains(callbacks)); m_databaseCallbacksSet.remove(callbacks); if (m_pendingSecondHalfOpenWithVersion && m_pendingSecondHalfOpenWithVersion->databaseCallbacks() == callbacks) { m_pendingSecondHalfOpenWithVersion->callbacks()->onError(IDBDatabaseError::create(IDBDatabaseException::IDB_ABORT_ERR, "The connection was closed.")); m_pendingSecondHalfOpenWithVersion.release(); } if (connectionCount() > 1) return; // processPendingCalls allows the inspector to process a pending open call // and call close, reentering IDBDatabaseBackendImpl::close. Then the // backend would be removed both by the inspector closing its connection, and // by the connection that first called close. // To avoid that situation, don't proceed in case of reentrancy. if (m_closingConnection) return; m_closingConnection = true; processPendingCalls(); // FIXME: Add a test for the m_pendingOpenCalls and m_pendingOpenWithVersionCalls cases below. if (!connectionCount() && !m_pendingOpenCalls.size() && !m_pendingOpenWithVersionCalls.size() && !m_pendingDeleteCalls.size()) { TransactionSet transactions(m_transactions); for (TransactionSet::const_iterator it = transactions.begin(); it != transactions.end(); ++it) (*it)->abort(); ASSERT(m_transactions.isEmpty()); m_backingStore.clear(); // This check should only be false in tests. if (m_factory) m_factory->removeIDBDatabaseBackend(m_identifier); } m_closingConnection = false; }
void TCPServer::stop() { if(!server) return; // Cleanup the server server->close(); server->deleteLater(); server = 0; emit connectionCount(socketMap.size()); emit warning(classname, "stopped"); }
void IDBDatabaseBackendImpl::runIntVersionChangeTransaction(int64_t requestedVersion, PassRefPtr<IDBCallbacks> prpCallbacks, PassRefPtr<IDBDatabaseCallbacks> prpDatabaseCallbacks) { RefPtr<IDBCallbacks> callbacks = prpCallbacks; RefPtr<IDBDatabaseCallbacks> databaseCallbacks = prpDatabaseCallbacks; ASSERT(callbacks); for (DatabaseCallbacksSet::const_iterator it = m_databaseCallbacksSet.begin(); it != m_databaseCallbacksSet.end(); ++it) { // Front end ensures the event is not fired at connections that have closePending set. if (*it != databaseCallbacks) (*it)->onVersionChange(m_metadata.intVersion, requestedVersion); } // The spec dictates we wait until all the version change events are // delivered and then check m_databaseCallbacks.empty() before proceeding // or firing a blocked event, but instead we should be consistent with how // the old setVersion (incorrectly) did it. // FIXME: Remove the call to onBlocked and instead wait until the frontend // tells us that all the blocked events have been delivered. See // https://bugs.webkit.org/show_bug.cgi?id=71130 if (connectionCount()) callbacks->onBlocked(m_metadata.intVersion); // FIXME: Add test for m_runningVersionChangeTransaction. if (m_runningVersionChangeTransaction || connectionCount()) { m_pendingOpenWithVersionCalls.append(PendingOpenWithVersionCall::create(callbacks, databaseCallbacks, requestedVersion)); return; } Vector<int64_t> objectStoreIds; RefPtr<IDBTransactionBackendInterface> transactionInterface = transaction(objectStoreIds, IDBTransaction::VERSION_CHANGE); RefPtr<IDBTransactionBackendImpl> transaction = IDBTransactionBackendImpl::from(transactionInterface.get()); RefPtr<IDBDatabaseBackendImpl> database = this; OwnPtr<ScriptExecutionContext::Task> intVersionTask = createCallbackTask(&IDBDatabaseBackendImpl::setIntVersionInternal, database, requestedVersion, callbacks, databaseCallbacks, transaction); OwnPtr<ScriptExecutionContext::Task> resetVersionOnAbortTask = createCallbackTask(&IDBDatabaseBackendImpl::resetVersion, database, m_metadata.version, m_metadata.intVersion); if (!transaction->scheduleTask(intVersionTask.release(), resetVersionOnAbortTask.release())) { ASSERT_NOT_REACHED(); } ASSERT(!m_pendingSecondHalfOpenWithVersion); m_databaseCallbacksSet.add(databaseCallbacks); }
void TCPServer::disconnectClient() { QTcpSocket* socket = (QTcpSocket*)sender(); // Cleanup specific socket clientMap[socket]->disconnect(); clientMap[socket]->deleteLater(); clientMap.remove(socket); socketMap[socket]->close(); socketMap[socket]->deleteLater(); socketMap.remove(socket); emit connectionCount(socketMap.size()); }
void TCPServer::connectClient() { emit info(classname, "adding new connection"); // Create socket and client while(server->hasPendingConnections()) { QTcpSocket *socket = server->nextPendingConnection(); QObject::connect(socket, SIGNAL(disconnected()), this, SLOT(disconnectClient())); socketMap[socket] = socket; TCPClient *client = new TCPClient(this); client->connect(socket); QObject::connect(client, SIGNAL(dataReceived(QByteArray)), this, SLOT(clientDataReceived(QByteArray))); QObject::connect(client, SIGNAL(info(QString,QString)), this, SLOT(clientInfo(QString,QString))); QObject::connect(client, SIGNAL(warning(QString,QString)), this, SLOT(clientWarning(QString,QString))); QObject::connect(client, SIGNAL(error(QString,QString)), this, SLOT(clientError(QString,QString))); clientMap[socket] = client; } emit connectionCount(socketMap.size()); }
void BuddyEditor::updateBackground() { if (m_updating || background() == 0) return; ConnectionEdit::updateBackground(); m_updating = true; QList<Connection *> newList; const LabelList label_list = background()->findChildren<QLabel*>(); foreach (QLabel *label, label_list) { const QString buddy_name = buddy(label, m_formWindow->core()); if (buddy_name.isEmpty()) continue; const QList<QWidget *> targets = background()->findChildren<QWidget*>(buddy_name); if (targets.isEmpty()) continue; QWidget *target = 0; QListIterator<QWidget *> it(targets); while (it.hasNext()) { QWidget *widget = it.next(); if (widget && !widget->isHidden()) { target = widget; break; } } if (target == 0) continue; Connection *con = new Connection(this); con->setEndPoint(EndPoint::Source, label, widgetRect(label).center()); con->setEndPoint(EndPoint::Target, target, widgetRect(target).center()); newList.append(con); } QList<Connection *> toRemove; const int c = connectionCount(); for (int i = 0; i < c; i++) { Connection *con = connection(i); QObject *source = con->object(EndPoint::Source); QObject *target = con->object(EndPoint::Target); bool found = false; QListIterator<Connection *> it(newList); while (it.hasNext()) { Connection *newConn = it.next(); if (newConn->object(EndPoint::Source) == source && newConn->object(EndPoint::Target) == target) { found = true; break; } } if (found == false) toRemove.append(con); } if (!toRemove.isEmpty()) { DeleteConnectionsCommand command(this, toRemove); command.redo(); foreach (Connection *con, toRemove) delete takeConnection(con); } QListIterator<Connection *> it(newList); while (it.hasNext()) { Connection *newConn = it.next(); bool found = false; const int c = connectionCount(); for (int i = 0; i < c; i++) { Connection *con = connection(i); if (con->object(EndPoint::Source) == newConn->object(EndPoint::Source) && con->object(EndPoint::Target) == newConn->object(EndPoint::Target)) { found = true; break; } } if (found == false) { AddConnectionCommand command(this, newConn); command.redo(); } else { delete newConn; } } m_updating = false; }
bool IDBDatabaseBackend::isDeleteDatabaseBlocked() { return connectionCount(); }
// --------------------------------------------------------- // CActiveDisconnectDlgPlugin::IsConnectionL // --------------------------------------------------------- // TBool CActiveDisconnectDlgPlugin::IsConnectionL( CConnectionInfo* aConnectionInfo ) { CLOG_ENTERFN( "CActiveDisconnectDlgPlugin::IsConnectionL" ); TBool result( EFalse ); TUint i( 0 ); TUint connectionCount( 0 ); TUint connNum( 0 ); TUint subConnectionCount( 0 ); TUint connId( 0 ); TInt bearer( 0 ); TInt connStatus( 0 ); //TRequestStatus status; TName apName; RConnectionMonitor connMon; result = connMon.ConnectL(); CLOG_WRITEF( _L( "result: %d" ), result ); CDisconnectDlgActiveWaiter* waiter = CDisconnectDlgActiveWaiter::NewL(); CleanupStack::PushL( waiter ); connMon.GetConnectionCount( connNum, waiter->iStatus ); waiter->WaitForRequest(); //User::WaitForRequest( status ); CLOG_WRITEF( _L( "status: %d" ), waiter->iStatus.Int() ); CLOG_WRITEF( _L( "connNum: %d" ), connNum ); for( i = 1; i < ( connNum + 1 ) && !connectionCount; ++i ) { connMon.GetConnectionInfo( i, connId, subConnectionCount ); connMon.GetStringAttribute( connId, 0, KIAPName, apName, waiter->iStatus ); waiter->WaitForRequest(); //User::WaitForRequest( status ); CLOG_WRITEF( _L( "KIAPName status: %d" ), waiter->iStatus.Int() ); connMon.GetIntAttribute( connId, 0, KBearer, bearer, waiter->iStatus ); waiter->WaitForRequest(); //User::WaitForRequest( status ); CLOG_WRITEF( _L( "KBearer status: %d" ), waiter->iStatus.Int() ); connMon.GetIntAttribute( connId, 0, KConnectionStatus, connStatus, waiter->iStatus ); waiter->WaitForRequest(); //User::WaitForRequest( status ); CLOG_WRITEF( _L( "KConnectionStatus status: %d" ), waiter->iStatus.Int() ); TUint iapId( 0 ); connMon.GetUintAttribute( connId, 0, KIAPId, iapId, waiter->iStatus ); waiter->WaitForRequest(); //User::WaitForRequest( status ); CLOG_WRITEF(_L( "KIAPId status: %d" ), waiter->iStatus.Int() ); CLOG_WRITEF(_L( "iapId: %d" ), iapId ); TConnMonTimeBuf timeBuf; connMon.GetPckgAttribute( connId, 0, KStartTime, timeBuf, waiter->iStatus ); waiter->WaitForRequest(); CLOG_WRITEF(_L( "KStartTime status: %d" ), waiter->iStatus.Int() ); switch( bearer ) { case EBearerGPRS : case EBearerEdgeGPRS : case EBearerExternalGPRS : case EBearerExternalEdgeGPRS : case EBearerWCDMA : case EBearerExternalWCDMA : #ifdef __WINS__ case EBearerLAN : #endif // WINS { if ( ( connStatus == KLinkLayerOpen ) || ( connStatus == KConnectionOpen && bearer >= EBearerExternalCSD ) ) { apName.Trim(); if( apName.Left( KMrouterName().Length() ). CompareF( KMrouterName ) ) { ++connectionCount; aConnectionInfo->SetIapNameL( apName ); aConnectionInfo->SetBearerType( bearer ); aConnectionInfo->SetConnId( connId ); aConnectionInfo->SetIAPId( iapId ); aConnectionInfo->SetStartTime( timeBuf() ); TConnMonClientEnumBuf clientEnum; connMon.GetPckgAttribute( connId, 0, KClientInfo, clientEnum, waiter->iStatus ); waiter->WaitForRequest(); //User::WaitForRequest( status ); aConnectionInfo->SetClientInfo( clientEnum() ); CLOG_WRITEF( _L( "KClientInfo status: %d" ), waiter->iStatus.Int() ); } } break; } default : { break; } } } CleanupStack::PopAndDestroy( waiter ); connMon.Close(); result = connectionCount ? ETrue : EFalse; CLOG_WRITEF( _L( "connectionCount: %d" ), connectionCount ); CLOG_WRITEF( _L( "result: %d" ), result ); CLOG_LEAVEFN( "CActiveDisconnectDlgPlugin::IsConnectionL" ); return result; }