void cTranscript::startAdvTranscript () { QString af; if (advrunning) stopAdvTranscript (); cTelnet *telnet = dynamic_cast<cTelnet *>(object ("telnet")); if (!(telnet->isConnected())) //no transcript if we aren't connected return; if(advfname.isEmpty()) return; // no transcript if advanced filename failed errno = 0; transtimer = new QTimer(); connect (transtimer, SIGNAL (timeout ()), this, SLOT (timeout ())); cProfileSettings *sett = settings (); af = sett ? sett->getString ("transcript-directory") : QDir::homePath(); af += advfname; advfile = fopen (af.toLatin1(), "a"); if (advfile == NULL) { KMessageBox::detailedSorry (cActionManager::self()->mainWidget(), i18n ("Advanced transcript file could not be opened."), strerror (errno)); errno = 0; invokeEvent ("message", sess(), i18n ("Advanced session transcript could not be started.")); } else { advrunning = true; cOutput *output = dynamic_cast<cOutput *>(object ("output")); fputs ("\n\n", advfile); if (advtype == TRANSCRIPT_HTML) { //TODO: what if we're adding to an existing HTML transcript? fputs ("<html>\n", advfile); fputs ("<meta name=\"Generator\" content=\"KMuddy\">\n", advfile); fputs ("<body bgcolor=", advfile); fputs (output->defaultBkColor().name().toLatin1(), advfile); fputs (">\n", advfile); } QString s = i18n ("Advanced session transcript has just started."); fputs (s.toLatin1(), advfile); if (advtype == TRANSCRIPT_HTML) fputs ("<br><pre>", advfile); //pre-formatted text starting... fputs ("\n\n", advfile); invokeEvent ("message", sess(), i18n ("Advanced session transcript has been started.")); if (rotatedaily) { invokeEvent ("message", sess(), i18n ("Session transcript will be rotated at midnight.")); transtimer->start (60000); } } }
void XplodifyPlaylist::playlist_metadata_updated(){ //If playlist metadata has been updated, we first check //for pending tracks that are ready.... boost::shared_ptr<XplodifySession> sess(m_session.lock()); track_cache_by_rand& tr_cache_rand = m_track_cache.get<0>(); typedef std::vector< boost::shared_ptr<XplodifyTrack> > wvec; wvec::iterator it; lock(); for (it=m_pending_tracks.begin() ; it != m_pending_tracks.end() ; ) { boost::shared_ptr<XplodifyTrack> t = *it; std::pair<track_r_iterator, bool> p; if(t->is_loaded()) { std::string trname(t->get_name()); track_entry tr_entry(trname, t); p = tr_cache_rand.push_back(tr_entry); if(p.second) { it = m_pending_tracks.erase(it); #ifdef _DEBUG std::cout << "Track " << t->get_name() << " loaded for playlist " << get_name() << std::endl; #endif } else { it++; } } else { it++; } } sess->update_state_ts(); unlock(); return; }
void cTranscript::stopTranscript () { if (!running) return; fputs ("\n\n", file); if (type == TRANSCRIPT_ANSI) //ANSI transcript { //set output color to default (usually gray on black) char defcolor[5]; defcolor[0] = 27; defcolor[1] = '['; defcolor[2] = '0'; defcolor[3] = 'm'; defcolor[4] = 0; fputs (defcolor, file); } if (type == TRANSCRIPT_HTML) //HTML transcript { //closing HTML tags fputs ("</pre></body></html>\n", file); } running = false; fclose (file); file = 0; invokeEvent ("message", sess(), i18n ("Session transcript has been stopped.")); }
void client::thread_func(unsigned n) { session sess(address_, port_); std::size_t message_sizes[] = { 0, 1, 3, 7, 234, 6432, 23221, 3311, 34, 4521, 333 }; for (auto s : message_sizes) { std::vector<uint8_t> mess(s, 'x'); try { const std::size_t cnt = 1024 * 10; for (std::size_t i = 0; i < cnt; ++i) sess.echo(mess); ostream_ << "#" << n << ": " << cnt << " echos (size " << mess.size() << " bytes) received" << std::endl; } catch (std::exception& e) { ostream_ << "#" << n << ": " << "Exception: " << e.what() << std::endl; } } }
static void run_tests_inner3L() { TNoDefaults nd; auto_ptr<CApp_context> c(CApp_context::NewL(true, _L("jaikutest"))); auto_ptr<CBaActiveScheduler> sched(new (ELeave) CBaActiveScheduler); CActiveScheduler::Install(sched.get()); c->SetDataDir(_L("c:\\system\\data\\context\\"), false); c->SetSettings(CBlackBoardSettings::NewL(*c, nd, KCLSettingsTuple)); auto_ptr<CBBDataFactory> f(CBBDataFactory::NewL()); c->SetBBDataFactory(f.get()); auto_ptr<CBBSession> sess(CBBSession::NewL(*c, f.get())); c->SetBBSession(sess.get()); c->SetActiveErrorReporter(output); c->BBSession()->DeleteL(KComponentVersionTuple, KNullDesC, ETrue); c->BBSession()->DeleteL(KComponentFunctionalityTuple, KNullDesC, ETrue); c->BBSession()->DeleteL(KComponentNameTuple, KNullDesC, ETrue); c->BBSession()->DeleteL(KComponentStateTuple, KNullDesC, ETrue); c->BBSession()->DeleteL(KComponentErrorCountTuple, KNullDesC, ETrue); c->BBSession()->DeleteL(KComponentErrorInfoTuple, KNullDesC, ETrue); auto_ptr<CBBRecovery> rec(CBBRecovery::NewL()); MRecovery::TState state=rec->GetState( TUid::Uid(1), 4 ); TEST_EQUALS( (TInt)state, (TInt)MRecovery::EUnknown, _L("recovery3:0:1")); rec->SetState(TUid::Uid(1), 4, MRecovery::ERunning ); state=rec->GetState( TUid::Uid(1), 4 ); TEST_EQUALS( (TInt)state, (TInt)MRecovery::ERunning, _L("recovery3:0:2")); rec->SetState(TUid::Uid(1), 4, MRecovery::EFailed); state=rec->GetState( TUid::Uid(1), 4 ); TEST_EQUALS( (TInt)state, (TInt)MRecovery::EFailed, _L("recovery3:0:3")); TInt errors=rec->GetErrorCount( TUid::Uid(1), 4 ); TEST_EQUALS( errors, 1, _L("recovery3:0:4")); }
void XplodifyPlaylist::tracks_added( sp_track * const *tracks, int num_tracks, int position) { #if 0 boost::shared_ptr<XplodifySession> sess(m_session.lock()); if(!sess) { return; } track_cache_by_rand& tr_cache_rand = m_track_cache.get<0>(); track_cache_by_rand::const_iterator cit = tr_cache_rand.begin(); //Fast forward cit = cit+position-1; for(int i=0 ; i<num_tracks ; i++) { boost::shared_ptr<XplodifyTrack> tr(new XplodifyTrack(sess)); std::pair<track_r_iterator, bool> p; if(tr->load(tracks[i])){ std::string trname(tr->get_name()); if(!trname.empty()) { p = tr_cache_rand.insert(cit, track_entry(trname, tr)); if(p.second) { cit++; } } } } sess->update_state_ts(); #endif return; }
QStringList cCmdParser::parseCommand (const QString &command, bool expandAliases) { QStringList result, res; bool aliasesExpanded = false; // look if this command should be sent as-is if ((noparsestr.length() > 0) && (command.startsWith (noparsestr))) { QString t = command.mid (noparsestr.length()); result.append (markAsRaw (t)); return result; } QString cmd = command; // we need to modify the command // first look if there isn't a repeater sequence // if not, then repeater keeps original command and returns 1, // so we can handle both situations together int rep = repeater (cmd); // perform alias expansion if (expandAliases) { cList *al = cListManager::self()->getList (sess(), "aliases"); cAliasList *aliases = al ? dynamic_cast<cAliasList *>(al) : 0; if (aliases && aliases->matchString (cmd)) { aliasesExpanded = true; QStringList cmds = aliases->commandsToExec (); QStringList::iterator it; for (it = cmds.begin(); it != cmds.end(); ++it) // recursive call, but this time no alias expansion will occur // (we don't want recursive aliases) res += parse (*it, false); } } // if we expanded aliases, these things were already done for commands in the list, hence we // only do this if no expansion occured if (!aliasesExpanded) { // expand backslashes expandBackslashes (cmd); // add the command to the list, expanding speed-walk if needed int spdpos = isSpeedWalkCommand (cmd); if (spdpos != -1) res = expandSpeedWalk (cmd, spdpos); else res.append (cmd); } // return results ... // only one repeat - return the resulting list if (rep == 1) return res; // more repeats - generate the result, using requested number of repeats for (int r = 0; r < rep; r++) result += res; return result; }
void get(const StringSlice& url, WriteTarget out) { static int inited = ne_sock_init(); if (inited != 0) { throw Exception("ne_sock_init()"); } CString cstr(url); ne_uri uri = {}; if (ne_uri_parse(cstr.data(), &uri)) { throw Exception("ne_uri_parse()"); } if (uri.port == 0) { uri.port = ne_uri_defaultport(uri.scheme); } unique_ptr<ne_uri, decltype(&ne_uri_free)> uri_free(&uri, ne_uri_free); unique_ptr<ne_session, decltype(&ne_session_destroy)> sess( ne_session_create(uri.scheme, uri.host, uri.port), ne_session_destroy); unique_ptr<ne_request, decltype(&ne_request_destroy)> req( ne_request_create(sess.get(), "GET", uri.path), ne_request_destroy); ne_userdata userdata = {out}; ne_add_response_body_reader(req.get(), accept, reader, &userdata); auto err = ne_request_dispatch(req.get()); if (err != NE_OK) { throw Exception("ne_request_dispatch()"); } auto* st = ne_get_status(req.get()); if (st->code != 200) { throw Exception(st->code); } }
void cTranscript::stopAdvTranscript () { if (!advrunning) return; fputs ("\n\n", advfile); if (type == TRANSCRIPT_ANSI) //ANSI transcript { //set output color to default (usually gray on black) char defcolor[5]; defcolor[0] = 27; defcolor[1] = '['; defcolor[2] = '0'; defcolor[3] = 'm'; defcolor[4] = 0; fputs (defcolor, advfile); } if (type == TRANSCRIPT_HTML) //HTML transcript { //closing HTML tags fputs ("</pre></body></html>\n", advfile); } advrunning = false; fclose (advfile); advfile = 0; if (transtimer->isActive ()) { transtimer->stop (); delete transtimer; } invokeEvent ("message", sess(), i18n ("Advanced session transcript has been stopped.")); }
void cTranscript::startTranscript () { //we'll have multiple <html></html> sections in a transcript file if we continue an existing //one, but every browser that I've tested can handle it correctly :D if (running) stopTranscript (); cTelnet *telnet = dynamic_cast<cTelnet *>(object ("telnet")); if (!(telnet->isConnected())) //no transcript if we aren't connected return; errno = 0; file = fopen (fname.toLatin1(), overwrite ? "w" : "a"); if (file == NULL) { KMessageBox::detailedSorry (cActionManager::self()->mainWidget(), i18n ("Transcript file could not be opened."), strerror (errno)); errno = 0; invokeEvent ("message", sess(), i18n ("Session transcript could not be started.")); } else { running = true; cOutput *output = dynamic_cast<cOutput *>(object ("output")); fputs ("\n\n", file); if (type == TRANSCRIPT_HTML) { //TODO: what if we're adding to an existing HTML transcript? fputs ("<html>\n", file); fputs ("<meta name=\"Generator\" content=\"KMuddy\">\n", file); fputs ("<body bgcolor=", file); fputs (output->defaultBkColor().name().toLatin1(), file); fputs (">\n", file); } QString s = i18n ("Session transcript has just started."); fputs (s.toLatin1(), file); if (type == TRANSCRIPT_HTML) fputs ("<br><pre>", file); //pre-formatted text starting... fputs ("\n\n", file); //add buffer dump if requested if (includedump) output->console()->dumpBuffer (false, file, type); invokeEvent ("message", sess(), i18n ("Session transcript has been started.")); } }
void MainWindow::on_Search_clicked() { remove("/home/baigoo365/Proj_2/index.txt"); session sess("http://www.boost.org/"); sess.stringsearch(s); Results results; results.setModal(true); results.exec(); }
void XplodifyPlaylist::add_track(boost::shared_ptr<XplodifyTrack> tr) { if(!tr) { return; } boost::shared_ptr<XplodifySession> sess(m_session.lock()); track_cache_by_rand& t_r = m_track_cache.get<0>(); //push_back() delivers better performance than insert. t_r.push_back(track_entry(tr->get_name(), tr)); sess->update_state_ts(); }
bool XplodifyPlaylist::unload() { boost::shared_ptr<XplodifySession> sess(m_session.lock()); sp_playlist_remove_callbacks(m_playlist, const_cast<sp_playlist_callbacks *>(&cbs), this); m_track_cache.get<0>().clear(); m_loading = false; m_playlist = NULL; sess->update_state_ts(); return true; }
unsigned int cCmdParser::repeater (QString &command) { bool multi = false; if ((multistr.length() > 0) && (command.startsWith (multistr))) multi = true; if (multi) //chance is that there is some repeater { QString cmd = command; cmd.remove (0, multistr.length()); cmd = cmd.trimmed (); QString rep = cmd.section (' ', 0, 0); //first section //if rep is a number, then this is a multi-command bool ok; unsigned int repc = rep.toUInt (&ok); if (ok) //GREAT!!! This really is a repeater command!!! { command = command.section (' ', 1); //everything except the 1st section //limit repeat count if needed cProfileSettings *sett = settings (); bool limitRepeats = ((sett == 0) ? true : sett->getBool ("limit-repeater")); if ((repc > 100) && limitRepeats) { invokeEvent ("message", sess(), i18n ("Sorry, count is limited to 100.\n")); if (sett) invokeEvent ("message", sess(), i18n ("You can disable this limit in Profile / MUD Preferences.")); //return 0 - nothing will be sent... return 0; } return repc; } else //no repeater here... return 1; } else //no repeater -> count is 1 return 1; }
void XplodifyPlaylist::flush() { boost::shared_ptr<XplodifySession> sess(m_session.lock()); track_cache_by_rand& t_r = m_track_cache.get<0>(); std::size_t sz = t_r.size(); for(std::size_t i=0 ; i<sz ; i++) { boost::shared_ptr<XplodifyTrack> tr = get_track(0, true); tr.reset(); } sess->update_state_ts(); }
static void test() { std::cout << "sizeof(Session) == " << sizeof(Session) << '\n'; std::cout << "sizeof(sock_) == " << sizeof(Session::sock_) << '\n'; std::cout << "sizeof(client_) == " << sizeof(Session::client_) << '\n'; std::cout << "sizeof(reverse_path_) == " << sizeof(Session::reverse_path_) << '\n'; std::cout << "sizeof(forward_path_) == " << sizeof(Session::forward_path_) << '\n'; std::cout << "sizeof(binarymime_) == " << sizeof(Session::binarymime_) << '\n'; setenv("GHSMTP_SERVER_ID", "digilicious.com", 1); int fd_null = open("/dev/null", O_WRONLY); PCHECK(fd_null >= 0) << " can't open /dev/null"; auto const config_path = osutil::get_config_dir(); auto read_hook = []() { std::cout << "Session-test read_hook\n"; }; Session sess(config_path, read_hook, STDIN_FILENO, fd_null); auto sender{Domain{"example.er"}}; auto error_msg{std::string{}}; CHECK(!sess.verify_sender_domain_(sender, error_msg)); // bogus CHECK(!sess.verify_sender_domain_( Domain("invalid-domain-has-only-one-lable"), error_msg)); // white listed CHECK(sess.verify_sender_domain_(Domain("lots.of.lables.digilicious.com"), error_msg)); CHECK(sess.verify_sender_domain_(Domain("whitelisted.digilicious.com"), error_msg)); CHECK(sess.verify_sender_domain_( Domain("reg-domain-is-whitelisted.digilicious.com"), error_msg)); // bounce address CHECK(sess.verify_sender_domain_(Domain(""), error_msg)); CHECK(!sess.verify_sender_domain_(Domain("com"), error_msg)); CHECK(!sess.verify_sender_domain_(Domain("zzux.com"), error_msg)); CHECK(!sess.verify_sender_domain_(Domain("blogspot.com.ar"), error_msg)); // SPF auto mb{Mailbox{"foo", "digilicious.com"}}; CHECK(sess.verify_sender_spf_(mb)); // IP address // auto error_msg{std::string{}}; // CHECK(!sess.verify_ip_address_("blacklisted.digilicious.com"s)); }
void cTranscript::save() { QString path = cProfileManager::self()->profilePath (sess()); KConfig *config = new KConfig ( path + "transcript"); KConfigGroup g = config->group ("Advanced transcript"); g.writeEntry ("Daily rotation", rotatedaily); g.writeEntry ("Prepend timestamp", includetimestamp); g.writeEntry ("Advanced logname", fileformat); g.writeEntry ("Transcript type", advtype); delete config; }
ioremap::elliptics::session create_session(ioremap::elliptics::node n, std::initializer_list<int> groups, uint64_t cflags, uint32_t ioflags) { session sess(n); sess.set_groups(std::vector<int>(groups)); sess.set_cflags(cflags); sess.set_ioflags(ioflags); sess.set_exceptions_policy(session::no_exceptions); return sess; }
void Worker::createClient(int fd, const char *host, int port) { //创建session对像 Session sess(nPid, fd); LOG("new client, fd=%d, host=%s, port=%d, sid=%s", fd, host, port, sess.getId()); //环镜变量 ClientData *pData = new ClientData(); char szPort[8]; int nPort = sprintf(szPort, "%d", port); pData->session = sess; pData->nrequest = 0; Backend::makeParam(pData->params, "REMOTE_ADDR", sizeof("REMOTE_ADDR") - 1, host, strlen(host)); Backend::makeParam(pData->params, "REMOTE_PORT", sizeof("REMOTE_PORT") - 1, szPort, nPort); Backend::makeParam(pData->params, "SESSIONID", sizeof("SESSIONID") - 1, sess.getId(), SID_LENGTH); //创建连接对像 Connection *client = new Connection(pEventLoop, fd); client->setHostAndPort(host, port); client->setData(pData); client->setMessageHandler(EV_CB(this, Worker::onMessage)); client->setCloseHandler(EV_CB(this, Worker::onClose)); //client->setWriteCompleteHandler(EL_CB(this, Worker::onWriteComplete)); arrClients[sess.getId()] = client; //计数更新 pMaster->addClient(nId); //Router通知 sendToRouter(ROUTER_MSG_CONN, SID_LENGTH, sess.getId(), 0, NULL); //backend通知 Config *pConfig = Config::getInstance(); if(pConfig->bEventConnect){ Backend *backend = new Backend(pEventLoop, client, NULL); backend->copyParam(pData->params); backend->addParam("EVENT", sizeof("EVENT") - 1, "1", 1); backend->setCloseHandler(EV_CB(this, Worker::onBackendClose)); backend->setResponseHandler(EV_CB(this, Worker::onBackendResponse)); if(backend->run()){ pData->backends[backend] = 1; }else{ delete backend; } } //lua通知 if(pMaster->pScript && pMaster->pScript->hasConnectProc()){ pMaster->pScript->procConnect(client); } }
void cTranscript::load() { QString path = cProfileManager::self()->profilePath (sess()); KConfig *config = new KConfig (path + "transcript"); KConfigGroup g = config->group ("Advanced transcript"); setEnableRotate (g.readEntry ("Daily rotation", false)); setPrependTimestamp (g.readEntry("Prepend timestamp", false)); setAFName (g.readEntry("Advanced logname", QString())); advtype = g.readEntry ("Transcript type", 1); delete config; }
shared_ptr <store> session::getStore( const utility::url& url, const shared_ptr <security::authenticator>& auth ) { shared_ptr <session> sess(dynamicCast <session>(shared_from_this())); shared_ptr <service> sv = serviceFactory::getInstance()->create(sess, url, auth); if (!sv || sv->getType() != service::TYPE_STORE) { return null; } return dynamicCast <store>(sv); }
void XplodifyPlaylist::tracks_removed(const int *tracks, int num_tracks) { boost::shared_ptr<XplodifySession> sess(m_session.lock()); //Assuming *tracks is ordered : CHECK THIS! for(int i=0 ; i<num_tracks ; i++) { boost::shared_ptr<XplodifyTrack> tr = remove_track_from_cache(tracks[num_tracks-i-1]); tr.reset(); } sess->update_state_ts(); return; }
void XplodifyPlaylist::add_track(boost::shared_ptr<XplodifyTrack> tr, int pos) { if(!tr) { return; } boost::shared_ptr<XplodifySession> sess(m_session.lock()); //get iterator... track_cache_by_rand& t_r = m_track_cache.get<0>(); track_cache_by_rand::iterator it = t_r.iterator_to(t_r[pos]); t_r.insert(it, track_entry(tr->get_name(), tr)); sess->update_state_ts(); }
shared_ptr <transport> session::getTransport( const string& protocol, const shared_ptr <security::authenticator>& auth ) { shared_ptr <session> sess(dynamicCast <session>(shared_from_this())); shared_ptr <service> sv = serviceFactory::getInstance()->create(sess, protocol, auth); if (!sv || sv->getType() != service::TYPE_TRANSPORT) { return null; } return dynamicCast <transport>(sv); }
boost::shared_ptr<XplodifyTrack> XplodifyPlaylist::remove_track_from_cache(int idx) { track_cache_by_rand& tr_cache_rand = m_track_cache.get<0>(); track_cache_by_rand::const_iterator cit = tr_cache_rand.begin(); cit = cit+idx-1; boost::shared_ptr<XplodifySession> sess(m_session.lock()); boost::shared_ptr<XplodifyTrack> ret_track(cit->track); tr_cache_rand.erase(cit); sess->update_state_ts(); return ret_track; }
static void run_tests_innerL() { TNoDefaults nd; auto_ptr<CApp_context> c(CApp_context::NewL(true, _L("jaikutest"))); auto_ptr<CBaActiveScheduler> sched(new (ELeave) CBaActiveScheduler); CActiveScheduler::Install(sched.get()); c->SetDataDir(_L("c:\\system\\data\\context\\"), false); c->SetSettings(CBlackBoardSettings::NewL(*c, nd, KCLSettingsTuple)); auto_ptr<CBBDataFactory> f(CBBDataFactory::NewL()); c->SetBBDataFactory(f.get()); auto_ptr<CBBSession> sess(CBBSession::NewL(*c, f.get())); c->SetBBSession(sess.get()); c->SetActiveErrorReporter(output); { auto_ptr<CComponent1> c1( new (ELeave) CComponent1 ); c1->ConstructL(); CActiveScheduler::Start(); TEST_EQUALS( 1, c1->iErrorCount, _L("comp1:1") ); } { TLogRecovery r; c->SetRecovery(&r); auto_ptr<CComponent1> c1( new (ELeave) CComponent1 ); c1->ConstructL(); CActiveScheduler::Start(); TEST_EQUALS( 1, c1->iErrorCount, _L("comp2:1") ); TEST_EQUALS( (TInt)MRecovery::ERestarting, (TInt)r.iState, _L("recovery:1") ); CActiveScheduler::Start(); TEST_EQUALS( 2, c1->iErrorCount, _L("comp2:2") ); TEST_EQUALS( (TInt)MRecovery::ERestarting, (TInt)r.iState, _L("recovery:2") ); CActiveScheduler::Start(); TEST_EQUALS( 3, c1->iErrorCount, _L("comp2:3") ); TEST_EQUALS( (TInt)MRecovery::ERestarting, (TInt)r.iState, _L("recovery:3") ); CActiveScheduler::Start(); TEST_EQUALS( 4, c1->iErrorCount, _L("comp2:4") ); TEST_EQUALS( (TInt)MRecovery::EFailed, (TInt)r.iState, _L("recovery:4") ); TInt stack_found=r.iErrorInfo->StackTrace().FindF(_L("StartL")); TEST_NOT_EQUALS(KErrNotFound, stack_found, _L("stack:1")); c->SetRecovery(0); } CActiveScheduler::Install(0); }
static void run_tests_inner4L() { RAChunk stackchunk; stackchunk.CreateGlobalLA(_L("jaikutest2"), 4096, 4096); { *(TInt*)stackchunk.Base()=0; char* iCallStackZero=(char*)stackchunk.Base() + 4; TInt iCallStackSize=stackchunk.Size(); TUint* uidp=(TUint*)(iCallStackZero+iCallStackSize-16); TInt* idp=(TInt*)(iCallStackZero+iCallStackSize-12); *uidp=0; *idp=0; } auto_ptr<CApp_context> c(CApp_context::NewL(true, _L("jaikutest"))); auto_ptr<CBaActiveScheduler> sched(new (ELeave) CBaActiveScheduler); CActiveScheduler::Install(sched.get()); TNoDefaults nd; c->SetDataDir(_L("c:\\system\\data\\context\\"), false); c->SetSettings(CBlackBoardSettings::NewL(*c, nd, KCLSettingsTuple)); auto_ptr<CBBDataFactory> f(CBBDataFactory::NewL()); c->SetBBDataFactory(f.get()); auto_ptr<CBBSession> sess(CBBSession::NewL(*c, f.get())); c->SetBBSession(sess.get()); auto_ptr<CBBRecovery> rec(CBBRecovery::NewL()); c->SetRecovery(rec.get()); MRecovery::TState state=MRecovery::EUnknown; while (state!=MRecovery::EDisabled) { RAThread thread; thread.CreateLA(_L("jaikutest3"), &run_thread_4, 20*1024, 128*1024, 32*1048*1024, 0); thread.SetPriority(EPriorityNormal); TRequestStatus s; thread.Logon(s); thread.Resume(); User::WaitForRequest(s); state=rec->GetState( TUid::Uid(5), 1 ); } TEST_EQUALS( (TInt)state, (TInt)MRecovery::EDisabled, _L("recovery4:0:1")); }
static void run_thread_4L() { auto_ptr<CApp_context> c(CApp_context::NewL(true, _L("jaikutest2"))); auto_ptr<CBaActiveScheduler> sched(new (ELeave) CBaActiveScheduler); CActiveScheduler::Install(sched.get()); c->SetDataDir(_L("c:\\system\\data\\context\\"), false); auto_ptr<CBBDataFactory> f(CBBDataFactory::NewL()); c->SetBBDataFactory(f.get()); auto_ptr<CBBSession> sess(CBBSession::NewL(*c, f.get())); c->SetBBSession(sess.get()); auto_ptr<CBBRecovery> rec(CBBRecovery::NewL()); c->SetRecovery(rec.get()); auto_ptr<CDyingComponent> d(new (ELeave) CDyingComponent); d->ConstructL(); CActiveScheduler::Start(); }
boost::shared_ptr<XplodifyTrack> XplodifyPlaylist::remove_track_from_cache(std::string& name){ track_cache_by_name& tr_cache_name = m_track_cache.get<1>(); track_cache_by_name::iterator it = tr_cache_name.find(name); if(it == tr_cache_name.end()) { return boost::shared_ptr<XplodifyTrack>(); } boost::shared_ptr<XplodifyTrack> ret_track(it->track); boost::shared_ptr<XplodifySession> sess(m_session.lock()); tr_cache_name.erase(name); sess->update_state_ts(); return ret_track; }
bool test_redis_session_attrs(const char* addr, int n) { std::map<acl::string, acl::session_string> attrs; acl::session_string value, name; for (int i = 0; i < n; i++) { name.format("name_%d", i); value.format("value_%d", i); attrs[name] = value; } acl::redis_client_cluster cluster(10, 10); cluster.set(addr, 1); acl::redis_session sess(cluster, 1); if (sess.set_attrs(attrs) == false) { printf("set_attrs error\r\n"); return false; } printf("set_attrs ok\r\n"); attrs.clear(); if (sess.get_attrs(attrs) == false) { printf("get_attrs error\r\n"); return false; } printf("get_attrs ok, n: %d\r\n", (int) attrs.size()); std::map<acl::string, acl::session_string>::const_iterator cit; for (cit = attrs.begin(); cit != attrs.end(); ++cit) printf("%s=%s\r\n", cit->first.c_str(), cit->second.c_str()); return true; }