Lines Matching refs:hSession

161     HSession hSession = hdcServer->MallocSession(true, CONN_USB, this);
162 if (!hSession) {
166 hSession->connectKey = hUSB->serialNumber;
171 hdcServer->FreeSession(hSession->sessionId);
175 waitTimeDoCmd->data = hSession;
182 void HdcHostUSB::KickoutZombie(HSession hSession)
184 HdcServer *ptrConnect = (HdcServer *)hSession->classInstance;
185 HUSB hUSB = hSession->hUSB;
187 WRITE_LOG(LOG_WARN, "KickoutZombie devHandle:%p isDead:%d", hUSB->devHandle, hSession->isDead);
195 ptrConnect->FreeSession(hSession->sessionId);
323 // hSession can be null
324 void HdcHostUSB::UpdateUSBDaemonInfo(HUSB hUSB, HSession hSession, uint8_t connStatus)
332 di.hSession = hSession;
438 void HdcHostUSB::CancelUsbIo(HSession hSession)
440 WRITE_LOG(LOG_INFO, "HostUSB CancelUsbIo, sid:%u ref:%u", hSession->sessionId, uint32_t(hSession->ref));
441 HUSB hUSB = hSession->hUSB;
465 HSession hSession = (HSession)stream->data;
466 unsigned int fd = hSession->dataFd[STREAM_MAIN];
500 hSession->stat.dataSendBytes += index;
539 int HdcHostUSB::SubmitUsbBio(HSession hSession, bool sendOrRecv, uint8_t *buf, int bufSize)
541 HUSB hUSB = hSession->hUSB;
564 hSession->sessionId, childRet);
570 hSession->sessionId, ep->transfer->status);
578 void HdcHostUSB::BeginUsbRead(HSession hSession)
580 HUSB hUSB = hSession->hUSB;
583 ++hSession->ref;
585 std::thread([this, hSession, hUSB]() {
589 while (!hSession->isDead) {
593 childRet = SubmitUsbBio(hSession, false, hUSB->hostBulkIn.buf, nextReadSize);
595 WRITE_LOG(LOG_FATAL, "Read usb failed, sid:%u ret:%d", hSession->sessionId, childRet);
600 if (hSession->isNeedDropData) {
601 hSession->dropBytes += childRet;
606 WRITE_LOG(LOG_WARN, "Read usb return 0, continue read, sid:%u", hSession->sessionId);
610 childRet = SendToHdcStream(hSession, reinterpret_cast<uv_stream_t *>(&hSession->dataPipe[STREAM_MAIN]),
613 WRITE_LOG(LOG_FATAL, "SendToHdcStream failed, sid:%u ret:%d", hSession->sessionId, childRet);
617 --hSession->ref;
620 server->FreeSession(hSession->sessionId);
622 WRITE_LOG(LOG_INFO, "Usb loop read finish sid:%u", hSession->sessionId);
659 int HdcHostUSB::SendUSBRaw(HSession hSession, uint8_t *data, const int length)
662 HdcSessionBase *server = reinterpret_cast<HdcSessionBase *>(hSession->classInstance);
663 ++hSession->ref;
664 ret = SubmitUsbBio(hSession, true, data, length);
666 WRITE_LOG(LOG_FATAL, "Send usb failed, sid:%u ret:%d", hSession->sessionId, ret);
667 CancelUsbIo(hSession);
668 hSession->hUSB->hostBulkOut.isShutdown = true;
669 server->FreeSession(hSession->sessionId);
671 --hSession->ref;
728 bool HdcHostUSB::ReadyForWorkThread(HSession hSession)
730 HdcUSBBase::ReadyForWorkThread(hSession);
735 HSession HdcHostUSB::ConnectDetectDaemon(const HSession hSession, const HDaemonInfo pdi)
738 HUSB hUSB = hSession->hUSB;
742 pServer->FreeSession(hSession->sessionId);
747 UpdateUSBDaemonInfo(hUSB, hSession, STATUS_CONNECTED);
748 hSession->isNeedDropData = true;
749 hSession->dropBytes = 0;
750 WRITE_LOG(LOG_INFO, "ConnectDetectDaemon set isNeedDropData true, sid:%u", hSession->sessionId);
751 BeginUsbRead(hSession);
753 WRITE_LOG(LOG_DEBUG, "HSession HdcHostUSB::ConnectDaemon, sid:%u", hSession->sessionId);
755 Base::StartWorkThread(&pServer->loopMain, pServer->SessionWorkThread, Base::FinishWorkThread, hSession);
757 while (hSession->childLoop.active_handles == 0) {
761 auto funcDelayStartSessionNotify = [hSession](const uint8_t flag, string &msg, const void *p) -> void {
762 HdcServer *pServer = (HdcServer *)hSession->classInstance;
764 hSession->isNeedDropData = false;
766 hSession->sessionId, uint64_t(hSession->dropBytes));
767 Base::SendToPollFd(hSession->ctrlFd[STREAM_MAIN], ctrl.data(), ctrl.size());
771 SendSoftResetToDaemon(hSession, 0);
773 return hSession;
776 void HdcHostUSB::SendSoftResetToDaemon(HSession hSession, uint32_t sessionIdOld)
778 HUSB hUSB = hSession->hUSB;
780 WRITE_LOG(LOG_INFO, "SendSoftResetToDaemon sid:%u sidOld:%u", hSession->sessionId, sessionIdOld);
782 if (SendUSBRaw(hSession, header.data(), header.size()) <= 0) {
786 WRITE_LOG(LOG_INFO, "SendSoftResetToDaemon sid:%u finished", hSession->sessionId);