//----------------------------------------------------------------------------- int ContextSP::_r_send_header() { if(_hdr.bytes()) { int err; if(_hdr.is_ssl == true) {//used when http proxy is configured in browser _sck_ssl_connect = true; LOGT("H CONNECT accepted"); err = _sock.sendall((const u_int8_t*)HTTP_200, strlen(HTTP_200), SS_TOUT); } else if(_hdr._nprx != 0){ _hdr.prep_doc(); err = _rock.sendall(_hdr.buf(), _hdr.bytes(), SS_TOUT); LOGT("H header sent: ["<<_hdr.bytes() <<"][" << _hdr.buf() << "]\n"); } _hdr.clear(); if(0!=err) { _s_send_reply(GENFAILURE); _rock.destroy(); throw Mex((REMOTE_CLOSED_ONSEND),__FILE__,__LINE__); } } if(_working) return 1; return Context::_r_send_header(); }
void testThread() { char arg1[] = "th1"; char arg2[] = "th2"; Thread th1((Thread::Routine)foo, arg1); Thread th2((Thread::Routine)foo, arg2); th1.setBackground(true); th1.start(); th2.start(); #ifdef _WIN32 Thread::sleep(500); th1.suspend(); LOGT("th1 was suspended."); Thread::sleep(500); th2.suspend(); LOGT("th2 was suspended."); Thread::sleep(500); th1.resume(); LOGT("th1 was resumed."); Thread::sleep(500); th2.resume(); LOGT("th2 was resumed."); #endif int ret2 = th2.join(); LOG_VAR(ret2); }
void IoServiceCore::start() { _netThread->run(); LOGT("Create net thread [ %s ]", _netThread->getThreadId()); _logicThread->run(); LOGT("Create main logic thread [ %s ]", _logicThread->getThreadId()); }
void run() { LOGT("hello"); while (this->getExit() == false) { LOGT("hello"); Thread::sleep(1000); } }
void Server::start() { while (!abortableWaitForConnection(socket, pipe[0])) { pool.execute(socket.accept()); } LOGT("Closed server main loop."); LOGT("Closing worker pool..."); pool.stop(); }
void server::handle_accept(const boost::system::error_code& e) { if (!e) { // handle connection LOGI("new connection, id="<<new_connection_->connection_id()); LOGT("Handle new connection ..."); LOGT("connection reference count: "<<new_connection_.use_count()); new_connection_->start(); LOGT("connection reference count after start: "<<new_connection_.use_count()); } // accept again start_accept(); }
int ContextSP::_parse_header() { if(_pending_hdr()==0) return 0; assert(!_sck_ssl_connect); //const bool con = _rock.check_connection(); if(_hdr._nhost) { char host[512]= {0}; char port[4] = "80"; ::strcpy(host, _hdr.get_host().c_str()); LOGT("H C: hdr ["<<_hdr.bytes() << "][" << _hdr.buf() << "]\n to: " << host); char* pp = strchr(host,':'); if(pp) { *pp++=0; } else { pp = port; } _raddr.port = ::atoi(pp); _raddr.ip = sock::dnsgetip(host); if(_raddr.ip.ipv4==0){ throw Mex(CANNOT_CONNECT,__FILE__,__LINE__); } if(_working ) { if(_rip == _raddr){ LOGT("H sending hdr to:"<< IP2STR(_rip.ip) << ":" << _rip.port); return _r_send_header(); } // else rip!=ap return _overwrite_connection(_raddr); } assert(!_rock.isopen()); if(_check_acl()) { return 0; } _rock.raw_sethost(_raddr.ip, htons(_raddr.port)); _rip = _raddr; return _rock_connect(); } if(_working) return _r_send_header(); throw Mex(CANNOT_PARSE_HTTP,__FILE__,__LINE__); }
void server::start_accept() { //>= 2^ 62 ++connection_id_; if ((connection_id_ >= 4611686018427387904) || (connection_id_ <= 0)) { connection_id_ = 1; } LOGT("start_accept, connection_id="<<connection_id_); //前一个connection不会释放吗?为什么? connection.start... 通过shared_from_this引用? LOGT("connection reference count: "<<new_connection_.use_count()); new_connection_.reset(new connection(io_service_pool_.get_io_service(), connection_id_)); LOGT("connection reference count: "<<new_connection_.use_count()); acceptor_.async_accept(new_connection_->socket(), boost::bind(&server::handle_accept, this, boost::asio::placeholders::error)); }
virtual void handle(int v) { if (v > 100) LOGT("T1 work"); else handleNext(v); }
virtual void handle(int v) { if (v < 50) LOGT("T2 work"); else handleNext(v); }
/**************************************************************************************************** * @fn OSPD_SubscribeResult * Enables subscription for results * ***************************************************************************************************/ osp_status_t OSPD_SubscribeResult(uint32_t sensorType, OSPD_ResultDataCallback_t dataReadyCallback ) { osp_status_t result = OSP_STATUS_OK; LOGT("%s\r\n", __FUNCTION__); return result; }
/**************************************************************************************************** * @fn OSPD_GetVersion * Helper routine for getting daemon version information * ***************************************************************************************************/ osp_status_t OSPD_GetVersion(char* versionString, int bufSize) { osp_status_t result = OSP_STATUS_OK; LOGT("%s\r\n", __FUNCTION__); return result; }
/**************************************************************************************************** * @fn OSPD_Deinitialize * Tear down RPC interface function * ***************************************************************************************************/ osp_status_t OSPD_Deinitialize(void) { osp_status_t result = OSP_STATUS_OK; LOGT("%s\r\n", __FUNCTION__); return result; }
/**************************************************************************************************** * @fn OSPD_UnsubscribeResult * Unsubscribe from sensor results * ***************************************************************************************************/ osp_status_t OSPD_UnsubscribeResult(uint32_t sensorType) { osp_status_t result = OSP_STATUS_OK; LOGT("%s\r\n", __FUNCTION__); return result; }
bool EmbedLiteAppThreadParent::RecvReadyToShutdown() { LOGT(); mApp->ChildReadyToDestroy(); return true; }
void testTimerHandler() { LOGT("<testTimerHandler>"); Timer t1, t2; TimerHandler handler; handler.attach(t1, timeout1); handler.attach(t2, timeout2); t1.setInterval(1); t2.setInterval(2); sw1.start(); sw2.start(); t1.start(); t2.start(); Thread::sleep(15); handler.detach(t2); Thread::sleep(30); t1.stop(); t2.stop(); Thread::sleep(105); }
void NetManager::event_onSessionDisconnect(TcpSessionPtr session) { LOGT("NetManager::event_onSessionDisconnect. SessionID=" << session->getSessionID() << ", remoteIP=" << session->getRemoteIP() << ", remotePort=" << session->getRemotePort()); if (isConnectID(session->getSessionID())) { } else { if (session->getUserParam() == SS_LOGINED) { auto info = UserManager::getRef().getInnerUserInfoBySID(session->getSessionID()); if (info) { UserManager::getRef().userLogout(info); info->sID = InvalidSeesionID; } } } if (UserManager::getRef().getAllOnlineUserCount() == 0 && _onSafeClosed) { SessionManager::getRef().post(_onSafeClosed); _onSafeClosed = nullptr; } }
CALLR CtxDns::_get_hostname() { DnsCommon dns; if(__dnsssl->deque_host(_cliip, _hdr.asll(), dns)) { LOGT(" found host from dns[" << IP2STR(_cliip) << "]<="<< dns.hostname); if(dns.domainip==0) { _raddr = __db->dnsgetip(dns.hostname); } else { _raddr = SADDR_46(dns.domainip); } _raddr.set_port(_pconf->conport ? _pconf->conport : 80); _set_rhost(_raddr); LOGD(_cliip.c_str() << " --r/dns--> "<< _raddr.c_str() ); return _host_connect(_r_socket); } else if(!_pconf->redirect.empty()) { //fallback _set_rhost(_pconf->toaddr, 0, 0); LOGD(_cliip.c_str() << " --r/cfg--> "<< _raddr.c_str() ); return _host_connect(_r_socket); } LOGE("No destination host found in queued hosts, neither in configuration. Connection closed"); return R_KILL; }
bool EmbedLiteAppThreadParent::DeallocPEmbedLiteView(PEmbedLiteViewParent* actor) { LOGT(); delete actor; return true; }
// ----------------------------------------------------------------------------- // CUpnpHttpServer::ConnectionAcceptedL // // ----------------------------------------------------------------------------- // CUpnpTcpSession* CUpnpHttpServer::ConnectionAcceptedL( RSocket aSocket ) { LOG_FUNC_NAME; #ifdef _DEBUG TInetAddr tempAddr; aSocket.RemoteName( tempAddr ); tempAddr.ConvertToV4(); const TInt KMaxAdressLength = 20; TBuf<KMaxAdressLength> addrBuf; tempAddr.Output( addrBuf ); HBufC8* addrBuf8 = UpnpString::FromUnicodeL( addrBuf ); CleanupStack::PushL( addrBuf8 ); LOGS( "CUpnpHttpServer::ConnectionAcceptedL - Remote socket connected" ); LOGT( addrBuf8->Des() ); LOGS1("CUpnpHttpServer::ConnectionAcceptedL - Creating a new Http session. Session count: %i", iSessionList.Count()); CleanupStack::PopAndDestroy(addrBuf8); #endif //_DEBUG CUpnpHttpSession* sess = CUpnpHttpSession::NewL( aSocket, this, CUpnpHttpMessage::NewSessionIdL(), EPriorityNormal ); return sess; }
void EmbedChromeManager::WindowDestroyed(nsIDOMWindow* aWin) { LOGT("WindowClosed: %p", aWin); nsCOMPtr<nsPIDOMWindow> pidomWindow = do_GetInterface(aWin); NS_ENSURE_TRUE(pidomWindow, ); nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(pidomWindow->GetChromeEventHandler()); NS_ENSURE_TRUE(target, ); nsCOMPtr<EmbedChromeListener> listener; int i = 0; for (i = 0; i < mArray.Count(); ++i) { if (mArray[i]->DOMWindow.get() == aWin) { listener = mArray[i]; break; } } mArray.RemoveObjectAt(i); target->RemoveEventListener(NS_LITERAL_STRING(MOZ_DOMContentLoaded), listener, PR_FALSE); target->RemoveEventListener(NS_LITERAL_STRING(MOZ_DOMLinkAdded), listener, PR_FALSE); target->RemoveEventListener(NS_LITERAL_STRING(MOZ_DOMWillOpenModalDialog), listener, PR_FALSE); target->RemoveEventListener(NS_LITERAL_STRING(MOZ_DOMModalDialogClosed), listener, PR_FALSE); target->RemoveEventListener(NS_LITERAL_STRING(MOZ_DOMWindowClose), listener, PR_FALSE); target->RemoveEventListener(NS_LITERAL_STRING(MOZ_DOMPopupBlocked), listener, PR_FALSE); target->RemoveEventListener(NS_LITERAL_STRING(MOZ_pageshow), listener, PR_FALSE); target->RemoveEventListener(NS_LITERAL_STRING(MOZ_pagehide), listener, PR_FALSE); target->RemoveEventListener(NS_LITERAL_STRING(MOZ_DOMMetaAdded), listener, PR_FALSE); mWindowCounter--; if (!mWindowCounter) { mService = nullptr; } }
int ContextSP::_get_from_rock() { if(!_rock.isopen()){return 0;} int rv = 0; int rsz; u_int8_t* buff = _pt->buffer(rsz); if(_rock.set() & 0x00000001) { size_t sz = _rock.receive(buff, rsz); if(sz == 0) { LOGW("H R xclosed"); _rock.destroy(); _sock.destroy(); return rv; } else if(sz > 0) { buff[sz] = 0; int ssz = _sock.sendall(buff, sz, SS_TOUT); if(0 != ssz) { LOGW("H C xclosed"); _rock.destroy(); _sock.destroy(); return rv; } LOGT("H receied [" << sz <<"]"); _stats._temp_bytes[BytesStats::eIN]+=sz; rv=1; //was some activity _load = (sz *100) / rsz; } return rv; } return 1; }
void process_proxyserverpacket(struct PL_entry *player, uint8_t pkttype, void * packet) { switch(pkttype) { case PID_HANDSHAKE: { struct packet_handshake* hpacket = (struct packet_handshake*) packet; if(bstrcmp(hpacket->username,bfromcstr("-")) != 0) { LOGT(LOG_INFO, "Remote server requires authentication"); bufferevent_free(player->sev); } send_proxylogin(player); return; } case PID_LOGIN: { return; // do nothing.. for now } case PID_KEEPALIVE: { return; // do nothing } } }
void * changer(void *) { for (int i = 0; i < 20; ++i) { conditionMutex.lock(); ++conditionVariable; if (conditionVariable % 3 == 0) { condition.notifyOne(); LOGT("mod 3"); } conditionMutex.unlock(); Thread::sleep(100); } conditionMutex.lock(); conditionVariable = ~0; conditionMutex.unlock(); condition.notifyOne(); return 0; }
EmbedLiteAppThreadParent::EmbedLiteAppThreadParent(MessageLoop* aParentLoop) : mApp(EmbedLiteApp::GetInstance()) , mParentLoop(aParentLoop) { LOGT(); MOZ_COUNT_CTOR(EmbedLiteAppThreadParent); sAppThreadParent = this; }
TEST_F(XLLoggerTest, testLogger) { LOGT("Trace log."); LOGD("Debug log."); LOGI("Hello"<<" World!"); LOGW("Warn: "<<123<<"!"); LOGE("Error: code="<<"-0x1111"); LOGF("Fatal: 严重错误,程序退出!code="<<0xfffffff); }
void game_touch(struct game* g, int touch_x, int touch_y) { struct pumpkin* p = &g->field[touch_x][touch_y]; LOGT("game_touch. x: %d, y: %d, count: %d", touch_x, touch_y, g->pumpkin_count); if (p->stage == PUMPKIN_NONE) create_new_pumpkin(g, touch_x, touch_y); else if (p->stage == PUMPKIN_RED && g->cart.state == CART_LOADING) { g->pumpkin_count--; g->pickup_count++; p->age = 0; p->stage = PUMPKIN_PICKING; g->cart.pumpkin_count++; LOGT("pickup pumpkin. picked count: %d. age: %.2ld", g->pickup_count, p->age); } }
bool DumpCallback(const google_breakpad::MinidumpDescriptor& descriptor, void* context, bool succeeded) { LOGT(); LOGD("Dump path: %s\n", descriptor.path()); return succeeded; }
void testTimerEvent() { LOGT("<testTimerEvent>"); Test t; t.setInterval(500); t.start(); Thread::sleep(3300); }
bool EmbedLiteAppThreadParent::RecvObserve(const nsCString& topic, const nsString& data) { LOGT("topic:%s", topic.get()); mApp->GetListener()->OnObserve(topic.get(), data.get()); return true; }