int runDaemon(int debug) { char packetPtr[PACKETLEN]; size_t packetSize; struct sockaddr_in sa; if (checkOtherProcess()) return (EXIT_FAILURE); signal(SIGTERM, sigHandler); signal(SIGINT, sigHandler); signal(SIGUSR1, sigHandler); if (!debug) { daemon(1, 1); if (savePid()) return EXIT_FAILURE; } fprintf(stderr, "Daemon started\n"); initConnection(&sa); while (1) { setClient(acceptClient(&sa)); bzero(packetPtr, PACKETLEN); getPacket(packetPtr, &packetSize); handlePacket(packetPtr, packetSize); setClient(-1); } setSock(-1); return EXIT_SUCCESS; }
MqttClient::MqttClient(uint8_t *ip, uint16_t port, MQTT_CALLBACK_SIGNATURE, Nokia_MqttClientAdapter& client, Stream& stream) { this->_state = MQTT_DISCONNECTED; setServer(ip,port); setCallback(callback); setClient(client); setStream(stream); }
void receivedUpdate(Message& m, stringstream& ss) { DbMessage d(m); const char *ns = d.getns(); assert(*ns); uassert( "not master", isMasterNs( ns ) ); setClient(ns); Client& client = cc(); client.top.setWrite(); ss << ns << ' '; int flags = d.pullInt(); BSONObj query = d.nextJsObj(); assert( d.moreJSObjs() ); assert( query.objsize() < m.data->dataLen() ); BSONObj toupdate = d.nextJsObj(); uassert("update object too large", toupdate.objsize() <= MaxBSONObjectSize); assert( toupdate.objsize() < m.data->dataLen() ); assert( query.objsize() + toupdate.objsize() < m.data->dataLen() ); bool upsert = flags & Option_Upsert; bool multi = flags & Option_Multi; { string s = query.toString(); /* todo: we shouldn't do all this ss stuff when we don't need it, it will slow us down. */ ss << " query: " << s; CurOp& currentOp = *client.curop(); strncpy(currentOp.query, s.c_str(), sizeof(currentOp.query)-2); } UpdateResult res = updateObjects(ns, toupdate, query, upsert, multi, ss, true); recordUpdate( res.existing , res.num ); // for getlasterror }
virtual bool run(const char *ns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool fromRepl) { string fromhost = cmdObj.getStringField("from"); if ( fromhost.empty() ) { errmsg = "missing from spec"; return false; } string collection = cmdObj.getStringField("cloneCollection"); if ( collection.empty() ) { errmsg = "missing cloneCollection spec"; return false; } BSONObj query = cmdObj.getObjectField("query"); if ( query.isEmpty() ) query = BSONObj(); BSONElement copyIndexesSpec = cmdObj.getField("copyindexes"); bool copyIndexes = copyIndexesSpec.isBoolean() ? copyIndexesSpec.boolean() : true; // Will not be used if doesn't exist. int logSizeMb = cmdObj.getIntField( "logSizeMb" ); /* replication note: we must logOp() not the command, but the cloned data -- if the slave were to clone it would get a different point-in-time and not match. */ setClient( collection.c_str() ); log() << "cloneCollection. db:" << ns << " collection:" << collection << " from: " << fromhost << " query: " << query << " logSizeMb: " << logSizeMb << ( copyIndexes ? "" : ", not copying indexes" ) << endl; Cloner c; long long cursorId; if ( !c.startCloneCollection( fromhost.c_str(), collection.c_str(), query, errmsg, !fromRepl, copyIndexes, logSizeMb, cursorId ) ) return false; return c.finishCloneCollection( fromhost.c_str(), collection.c_str(), query, cursorId, errmsg); }
PubSubClient::PubSubClient(uint8_t *ip, uint16_t port, MQTT_CALLBACK_SIGNATURE, Client& client) { this->_state = MQTT_DISCONNECTED; setServer(ip, port); setCallback(callback); setClient(client); this->stream = NULL; }
PubSubClient::PubSubClient(const char* domain, uint16_t port, Client& client, Stream& stream) { this->_state = MQTT_DISCONNECTED; setServer(domain,port); setClient(client); setStream(stream); setProtocol(MQTT_VERSION); }
PubSubClient::PubSubClient(IPAddress addr, uint16_t port, Client& client) { this->_state = MQTT_DISCONNECTED; setServer(addr, port); setClient(client); this->stream = NULL; setProtocol(MQTT_VERSION); }
void run() { dblock lk; const char *ns = "unittests.cursortests.BtreeCursorTests.MultiRangeGap"; { DBDirectClient c; for( int i = 0; i < 10; ++i ) c.insert( ns, BSON( "a" << i ) ); for( int i = 100; i < 110; ++i ) c.insert( ns, BSON( "a" << i ) ); ASSERT( c.ensureIndex( ns, BSON( "a" << 1 ) ) ); } BoundList b; b.push_back( pair< BSONObj, BSONObj >( BSON( "" << -50 ), BSON( "" << 2 ) ) ); b.push_back( pair< BSONObj, BSONObj >( BSON( "" << 40 ), BSON( "" << 60 ) ) ); b.push_back( pair< BSONObj, BSONObj >( BSON( "" << 109 ), BSON( "" << 200 ) ) ); setClient( ns ); BtreeCursor c( nsdetails( ns ), 1, nsdetails( ns )->indexes[ 1 ], b, 1 ); ASSERT_EQUALS( "BtreeCursor a_1 multi", c.toString() ); double expected[] = { 0, 1, 2, 109 }; for( int i = 0; i < 4; ++i ) { ASSERT( c.ok() ); ASSERT_EQUALS( expected[ i ], c.currKey().firstElement().number() ); c.advance(); } ASSERT( !c.ok() ); }
bool Client::shutdown(){ _shutdown = true; { boostlock bl(clientsMutex); clients.erase(this); } bool didAnything = false; if ( _tempCollections.size() ){ didAnything = true; for ( list<string>::iterator i = _tempCollections.begin(); i!=_tempCollections.end(); i++ ){ string ns = *i; dblock l; setClient( ns.c_str() ); if ( ! nsdetails( ns.c_str() ) ) continue; try { string err; BSONObjBuilder b; dropCollection( ns , err , b ); } catch ( ... ){ log() << "error dropping temp collection: " << ns << endl; } } _tempCollections.clear(); } return didAnything; }
void ResourceHandle::receivedCredential(const AuthenticationChallenge& challenge, const Credential& credential) { ASSERT(!challenge.isNull()); if (challenge != d->m_currentWebChallenge) return; if (credential.isEmpty()) { receivedRequestToContinueWithoutCredential(challenge); return; } KURL urlToStore; urlToStore = d->m_request.url(); CredentialStorage::set(credential, challenge.protectionSpace(), urlToStore); clearAuthentication(); // Clone our ResourceHandle and add it so that it is send with the credential. // FIXME: We should have a way of cloning an handle. RefPtr<ResourceHandle> newHandle = ResourceHandle::create(request(), client(), 0, d->m_defersLoading, shouldContentSniff()); setClient(0); // Clear the client to avoid it being cleared by WebCore. AuthenticationChallenge newAuthenticationChallenge(challenge.protectionSpace(), credential, challenge.previousFailureCount() + 1, challenge.failureResponse(), challenge.error()); // Store the new authentication challenge. newHandle->getInternal()->m_currentWebChallenge = newAuthenticationChallenge; d->m_cancelled = true; }
void HostItem::update(const Job &job) { setIsCompiling(job.state() == Job::Compiling); setClient(job.client()); if (job.state() == Job::WaitingForCS) return; bool finished = job.state() == Job::Finished || job.state() == Job::Failed; JobList::Iterator it = m_jobs.find(job.jobId()); bool newJob = (it == m_jobs.end()); if (newJob && finished) return; if (!newJob && !finished) return; if (newJob) { m_jobs.insert(job.jobId(), job); createJobHalo(job); } else if (finished) { deleteJobHalo(job); m_jobs.erase(it); } }
PubSubClient::PubSubClient(const char* domain, uint16_t port, Client& client, Stream& stream) { this->_state = MQTT_DISCONNECTED; setServer(domain,port); setClient(client); setStream(stream); setListener(NULL); // TOAST }
PubSubClient::PubSubClient(uint8_t *ip, uint16_t port, Client& client, Stream& stream) { this->_state = MQTT_DISCONNECTED; setServer(ip,port); setClient(client); setStream(stream); setListener(NULL); // TOAST }
PubSubClient::PubSubClient(IPAddress addr, uint16_t port, Client& client) { this->_state = MQTT_DISCONNECTED; setServer(addr, port); setClient(client); this->stream = NULL; setListener(NULL); // TOAST }
MqttClient::MqttClient(const char* domain, uint16_t port, MQTT_CALLBACK_SIGNATURE, Nokia_MqttClientAdapter& client) { this->_state = MQTT_DISCONNECTED; setServer(domain,port); setCallback(callback); setClient(client); this->stream = NULL; }
/*------------------------------------------------------------------------------ | MyFrame::MyFrame | ------------------------------------------------------------------------------*/ MyFrame::MyFrame( ) : IFrameWindow( "Manipulating Dialogues in C++", ID_MYFRAME, IFrameWindow::defaultStyle() | IFrameWindow::shellPosition ), clientCanvas( FID_CLIENT, this, this ), createButton ( ID_CREATEBUTTON, &clientCanvas, &clientCanvas ), quitButton ( DID_CANCEL, &clientCanvas, &clientCanvas ), pSampleDlg( 0 ), commandHandler( *this ) { createButton .setText( "Create Dialogue" ) .enableTabStop(); quitButton .setText( "Quit" ) .enableTabStop(); commandHandler.handleEventsFor( this ); setClient( &clientCanvas ); sizeTo( ISize( 100, 100) + clientCanvas.minimumSize( ) ); show(); setFocus(); }
void testTheDb() { stringstream ss; setClient("sys.unittest.pdfile"); /* this is not validly formatted, if you query this namespace bad things will happen */ theDataFileMgr.insert("sys.unittest.pdfile", (void *) "hello worldx", 13); theDataFileMgr.insert("sys.unittest.pdfile", (void *) "hello worldx", 13); BSONObj j1((const char *) &js1); deleteObjects("sys.unittest.delete", j1, false); theDataFileMgr.insert("sys.unittest.delete", &js1, sizeof(js1)); deleteObjects("sys.unittest.delete", j1, false); updateObjects("sys.unittest.delete", j1, j1, true,ss); updateObjects("sys.unittest.delete", j1, j1, false,ss); auto_ptr<Cursor> c = theDataFileMgr.findAll("sys.unittest.pdfile"); while ( c->ok() ) { c->_current(); c->advance(); } out() << endl; database = 0; }
void KSpellConfig::sChangeClient( int i ) { setClient( i ); // read in new dict list if ( dictcombo ) { if ( iclient == KS_CLIENT_ISPELL ) getAvailDictsIspell(); else if ( iclient == KS_CLIENT_HSPELL ) { langfnames.clear(); dictcombo->clear(); dictcombo->insertItem( i18n("Hebrew") ); sChangeEncoding( KS_E_CP1255 ); } else if ( iclient == KS_CLIENT_ZEMBEREK ) { langfnames.clear(); dictcombo->clear(); dictcombo->insertItem( i18n("Turkish") ); sChangeEncoding( KS_E_UTF8 ); } else getAvailDictsAspell(); } emit configChanged(); }
SocketStreamHandle::~SocketStreamHandle() { LOG(Network, "SocketStreamHandle %p delete", this); // If for some reason we were destroyed without closing, ensure that we are deactivated. deactivateHandle(this); setClient(0); }
// Konsttruktor f�r Hauptfenster MDIFrame (const char *title, const IResourceId &r = IC_DEFAULT_FRAME_ID, const IFrameWindow::Style &s = defaultStyle ()) : IFrameWindow (title, r, s), Client (0x8008, this, this) { setClient (&Client); }
PubSubClient::PubSubClient(uint8_t *ip, uint16_t port, Client& client, Stream& stream) { this->_state = MQTT_DISCONNECTED; setServer(ip,port); setClient(client); setStream(stream); setProtocol(MQTT_VERSION); }
PubSubClient::PubSubClient(IPAddress addr, uint16_t port, Client& client, Stream& stream) { this->_state = MQTT_DISCONNECTED; setServer(addr,port); setClient(client); setStream(stream); }
PubSubClient::PubSubClient(IPAddress addr, uint16_t port, MQTT_CALLBACK_SIGNATURE, Client& client, Stream& stream) { this->_state = MQTT_DISCONNECTED; setServer(addr,port); setCallback(callback); setClient(client); setStream(stream); }
PubSubClient::PubSubClient(uint8_t *ip, uint16_t port, Client& client) { this->_state = MQTT_DISCONNECTED; setServer(ip, port); setClient(client); this->stream = NULL; }
PubSubClient::PubSubClient(const char* domain, uint16_t port, MQTT_CALLBACK_SIGNATURE, Client& client, Stream& stream) { this->_state = MQTT_DISCONNECTED; setServer(domain,port); setCallback(callback); setClient(client); setStream(stream); }
PubSubClient::PubSubClient(const char* domain, uint16_t port, Client& client) { this->_state = MQTT_DISCONNECTED; setServer(domain,port); setClient(client); this->stream = NULL; }
virtual bool run(const char *ns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool fromRepl) { BSONObj fromToken = cmdObj.getObjectField("finishCloneCollection"); if ( fromToken.isEmpty() ) { errmsg = "missing finishCloneCollection finishToken spec"; return false; } string fromhost = fromToken.getStringField( "fromhost" ); if ( fromhost.empty() ) { errmsg = "missing fromhost spec"; return false; } string collection = fromToken.getStringField("collection"); if ( collection.empty() ) { errmsg = "missing collection spec"; return false; } BSONObj query = fromToken.getObjectField("query"); if ( query.isEmpty() ) { query = BSONObj(); } long long cursorId = 0; BSONElement cursorIdToken = fromToken.getField( "cursorId" ); if ( cursorIdToken.type() == Date ) { cursorId = cursorIdToken._numberLong(); } setClient( collection.c_str() ); log() << "finishCloneCollection. db:" << ns << " collection:" << collection << " from: " << fromhost << " query: " << query << endl; Cloner c; return c.finishCloneCollection( fromhost.c_str(), collection.c_str(), query, cursorId, errmsg ); }
//------------------------------------------------------------------------------------- bool ScriptDefModule::addClientMethodDescription(const char* attrName, MethodDescription* methodDescription) { if(hasPropertyName(attrName)) { ERROR_MSG(fmt::format("ScriptDefModule::addClientMethodDescription: There is a property[{}] name conflict!\n", attrName)); return false; } if (hasComponentName(attrName)) { ERROR_MSG(fmt::format("ScriptDefModule::addClientMethodDescription: There is a component[{}] name conflict!\n", attrName)); return false; } MethodDescription* f_methodDescription = findClientMethodDescription(attrName); if(f_methodDescription) { ERROR_MSG(fmt::format("ScriptDefModule::addClientMethodDescription: [{}] is exist!\n", attrName)); return false; } setClient(true); methodClientDescr_[attrName] = methodDescription; methodClientDescr_uidmap_[methodDescription->getUType()] = methodDescription; return true; }
void receivedGetMore(DbResponse& dbresponse, /*AbstractMessagingPort& dbMsgPort, */Message& m, stringstream& ss) { DbMessage d(m); const char *ns = d.getns(); ss << ns; setClient(ns); cc().top.setRead(); int ntoreturn = d.pullInt(); long long cursorid = d.pullInt64(); ss << " cid:" << cursorid; ss << " ntoreturn:" << ntoreturn; QueryResult* msgdata; try { AuthenticationInfo *ai = currentClient.get()->ai; uassert("unauthorized", ai->isAuthorized(cc().database()->name.c_str())); msgdata = getMore(ns, ntoreturn, cursorid, ss); } catch ( AssertionException& e ) { ss << " exception " + e.toString(); msgdata = emptyMoreResult(cursorid); } Message *resp = new Message(); resp->setData(msgdata, true); ss << " bytes:" << resp->data->dataLen(); ss << " nreturned:" << msgdata->nReturned; dbresponse.response = resp; dbresponse.responseTo = m.data->id; //dbMsgPort.reply(m, resp); }
MqttClient::MqttClient(IPAddress addr, uint16_t port, MQTT_CALLBACK_SIGNATURE, Nokia_MqttClientAdapter& client) { this->_state = MQTT_DISCONNECTED; setServer(addr, port); setCallback(callback); setClient(client); this->stream = NULL; }