Ejemplo n.º 1
0
static void callLayoutTestControllerCallback(unsigned index)
{
    if (!callbackMap().contains(index))
        return;
    WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page());
    JSContextRef context = WKBundleFrameGetJavaScriptContext(mainFrame);
    JSObjectRef callback = JSValueToObject(context, callbackMap().take(index), 0);
    JSObjectCallAsFunction(context, callback, JSContextGetGlobalObject(context), 0, 0, 0);
    JSValueUnprotect(context, callback);
}
Ejemplo n.º 2
0
static void cacheLayoutTestControllerCallback(unsigned index, JSValueRef callback)
{
    if (!callback)
        return;

    WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page());
    JSContextRef context = WKBundleFrameGetJavaScriptContext(mainFrame);
    JSValueProtect(context, callback);
    callbackMap().add(index, callback);
}
Ejemplo n.º 3
0
void ClientImpl::finalizeAuthentication(PendingConnection* pc, struct bufferevent *bev) throw (voltdb::Exception, voltdb::ConnectException){

    logMessage(ClientLogger::DEBUG, "ClientImpl::finalizeAuthentication");

    FreeBEVOnFailure protector(bev);
    if (pc->m_loginExchangeCompleted) {

        logMessage(ClientLogger::DEBUG, "ClientImpl::finalizeAuthentication OK");

        if (!m_instanceIdIsSet) {
            m_instanceIdIsSet = true;
            m_clusterStartTime = pc->m_response.clusterStartTime();
            m_leaderAddress = pc->m_response.leaderAddress();
        } else {
            if (m_clusterStartTime != pc->m_response.clusterStartTime() ||
                m_leaderAddress != pc->m_response.leaderAddress()) {
                throw ClusterInstanceMismatchException();
            }
        }
        //save event for host id
        m_hostIdToEvent[pc->m_response.hostId()] = bev;
        bufferevent_setwatermark( bev, EV_READ, 4, HIGH_WATERMARK);
        m_bevs.push_back(bev);

        m_contexts[bev] =
               boost::shared_ptr<CxnContext>(
                   new CxnContext(pc->m_hostname, pc->m_port));
        boost::shared_ptr<CallbackMap> callbackMap(new CallbackMap());
        m_callbacks[bev] = callbackMap;

        //Add callback for Topology Notification to map for magic volt session id
        boost::shared_ptr<TopologyNotificationCallback> topoNotificationCallback(new TopologyNotificationCallback(&m_distributer));
        callbackMap->insert(std::pair< int64_t, boost::shared_ptr<ProcedureCallback> >(VOLT_NOTIFICATION_MAGIC_NUMBER, topoNotificationCallback));

        bufferevent_setcb(
               bev,
               voltdb::regularReadCallback,
               voltdb::regularWriteCallback,
               voltdb::regularEventCallback, this);

        {
            boost::mutex::scoped_lock lock(m_pendingConnectionLock);
            for (std::list<PendingConnectionSPtr>::iterator i = m_pendingConnectionList.begin(); i != m_pendingConnectionList.end(); ++i) {
                if (i->get() == pc) {
                    m_pendingConnectionList.erase(i);
                    m_pendingConnectionSize.store(m_pendingConnectionList.size(), boost::memory_order_release);
                    break;
                }
            }
        }

        //update topology info and procedures info
        if (m_useClientAffinity) {
            updateHashinator();
            subscribeToTopologyNotifications();
        }

    	std::stringstream ss;
    	ss << "connectionActive " << m_contexts[bev]->m_name << ":" << m_contexts[bev]->m_port ;
    	logMessage(ClientLogger::INFO, ss.str());

        //Notify client that a connection was active
        if (m_listener.get() != NULL) {
            try {

                 m_listener->connectionActive( m_contexts[bev]->m_name, m_bevs.size() );
            } catch (const std::exception& e) {
                std::cerr << "Status listener threw exception on connection active: " << e.what() << std::endl;
            }
        }

    }
    else {


        logMessage(ClientLogger::DEBUG, "ClientImpl::finalizeAuthentication Fail");

    	std::stringstream ss;
    	ss << "connection failed " << " " << pc->m_hostname << ":" << pc->m_port;
    	logMessage(ClientLogger::ERROR, ss.str());

        throw ConnectException();
    }
            protector.success();
}