Lines Matching refs:hChannel
96 HChannel hChannel = (HChannel)v.second; in ClearChannels() local
97 if (!hChannel->isDead) { in ClearChannels()
98 FreeChannel(hChannel->channelId); in ClearChannels()
117 HChannel hChannel = (HChannel)tcp->data; in ReadStream() local
118 HdcChannelBase *thisClass = (HdcChannelBase *)hChannel->clsChannel; in ReadStream()
136 hChannel->availTailIndex += nread; in ReadStream()
138 while (hChannel->availTailIndex > DWORD_SERIALIZE_SIZE) { in ReadStream()
139 size = ntohl(*reinterpret_cast<uint32_t *>(hChannel->ioBuf + indexBuf)); // big endian in ReadStream()
144 if (hChannel->availTailIndex - DWORD_SERIALIZE_SIZE < size) { in ReadStream()
147 childRet = thisClass->ReadChannel(hChannel, reinterpret_cast<uint8_t *>(hChannel->ioBuf) + in ReadStream()
150 if (!hChannel->keepAlive) { in ReadStream()
156 hChannel->availTailIndex -= (DWORD_SERIALIZE_SIZE + size); in ReadStream()
159 if (indexBuf > 0 && hChannel->availTailIndex > 0) { in ReadStream()
160 …if (memmove_s(hChannel->ioBuf, hChannel->bufSize, hChannel->ioBuf + indexBuf, hChannel->availTailI… in ReadStream()
168 thisClass->FreeChannel(hChannel->channelId); in ReadStream()
175 HChannel hChannel = (HChannel)req->handle->data; in WriteCallback() local
176 --hChannel->ref; in WriteCallback()
177 HdcChannelBase *thisClass = (HdcChannelBase *)hChannel->clsChannel; in WriteCallback()
180 if (!hChannel->isDead && !hChannel->ref) { in WriteCallback()
181 thisClass->FreeChannel(hChannel->channelId); in WriteCallback()
264 void HdcChannelBase::SendChannelWithCmd(HChannel hChannel, const uint16_t commandFlag, uint8_t *buf… in SendChannelWithCmd() argument
282 SendChannel(hChannel, data, size + sizeof(commandFlag)); in SendChannelWithCmd()
289 HChannel hChannel = reinterpret_cast<HChannel>(AdminChannel(OP_QUERY_REF, channelId, nullptr)); in SendWithCmd() local
290 if (!hChannel) { in SendWithCmd()
294 if (hChannel->isDead) { in SendWithCmd()
297 SendChannelWithCmd(hChannel, commandFlag, bufPtr, size); in SendWithCmd()
299 --hChannel->ref; in SendWithCmd()
302 void HdcChannelBase::SendChannel(HChannel hChannel, uint8_t *bufPtr, const int size) in SendChannel() argument
316 if (hChannel->hWorkThread == uv_thread_self()) { in SendChannel()
317 sendStream = (uv_stream_t *)&hChannel->hWorkTCP; in SendChannel()
319 sendStream = (uv_stream_t *)&hChannel->hChildWorkTCP; in SendChannel()
322 ++hChannel->ref; in SendChannel()
333 HChannel hChannel = reinterpret_cast<HChannel>(AdminChannel(OP_QUERY_REF, channelId, nullptr)); in Send() local
334 if (!hChannel) { in Send()
338 if (hChannel->isDead) { in Send()
341 SendChannel(hChannel, bufPtr, size); in Send()
343 --hChannel->ref; in Send()
365 auto hChannel = new HdcChannel(); in MallocChannel() local
366 if (!hChannel) { in MallocChannel()
369 hChannel->stdinTty.data = nullptr; in MallocChannel()
370 hChannel->stdoutTty.data = nullptr; in MallocChannel()
373 hChannel->serverOrClient = isServerOrClient; in MallocChannel()
376 uv_tcp_init(loopMain, &hChannel->hWorkTCP); in MallocChannel()
377 ++hChannel->uvHandleRef; in MallocChannel()
378 hChannel->hWorkThread = uv_thread_self(); in MallocChannel()
379 hChannel->hWorkTCP.data = hChannel; in MallocChannel()
380 hChannel->clsChannel = this; in MallocChannel()
381 hChannel->channelId = channelId; in MallocChannel()
382 (void)memset_s(&hChannel->hChildWorkTCP, sizeof(hChannel->hChildWorkTCP), 0, sizeof(uv_tcp_t)); in MallocChannel()
383 AdminChannel(OP_ADD, channelId, hChannel); in MallocChannel()
384 *hOutChannel = hChannel; in MallocChannel()
392 HChannel hChannel = (HChannel)handle->data; in FreeChannelFinally() local
393 HdcChannelBase *thisClass = (HdcChannelBase *)hChannel->clsChannel; in FreeChannelFinally()
394 if (hChannel->uvHandleRef > 0) { in FreeChannelFinally()
397 thisClass->NotifyInstanceChannelFree(hChannel); in FreeChannelFinally()
398 thisClass->AdminChannel(OP_REMOVE, hChannel->channelId, nullptr); in FreeChannelFinally()
399 WRITE_LOG(LOG_DEBUG, "!!!FreeChannelFinally channelId:%u finish", hChannel->channelId); in FreeChannelFinally()
400 if (!hChannel->serverOrClient) { in FreeChannelFinally()
403 delete hChannel; in FreeChannelFinally()
407 void HdcChannelBase::FreeChannelContinue(HChannel hChannel) in FreeChannelContinue() argument
418 hChannel->availTailIndex = 0; in FreeChannelContinue()
419 if (hChannel->ioBuf) { in FreeChannelContinue()
420 delete[] hChannel->ioBuf; in FreeChannelContinue()
421 hChannel->ioBuf = nullptr; in FreeChannelContinue()
423 if (!hChannel->serverOrClient) { in FreeChannelContinue()
424 Base::TryCloseHandle((uv_handle_t *)&hChannel->stdinTty, closeChannelHandle); in FreeChannelContinue()
425 Base::TryCloseHandle((uv_handle_t *)&hChannel->stdoutTty, closeChannelHandle); in FreeChannelContinue()
427 if (uv_is_closing((const uv_handle_t *)&hChannel->hWorkTCP)) { in FreeChannelContinue()
428 --hChannel->uvHandleRef; in FreeChannelContinue()
430 Base::TryCloseHandle((uv_handle_t *)&hChannel->hWorkTCP, closeChannelHandle); in FreeChannelContinue()
432 Base::IdleUvTask(loopMain, hChannel, FreeChannelFinally); in FreeChannelContinue()
437 HChannel hChannel = (HChannel)handle->data; in FreeChannelOpeate() local
438 HdcChannelBase *thisClass = (HdcChannelBase *)hChannel->clsChannel; in FreeChannelOpeate()
439 if (hChannel->ref > 0) { in FreeChannelOpeate()
442 if (hChannel->hChildWorkTCP.loop) { in FreeChannelOpeate()
443 … auto ctrl = HdcSessionBase::BuildCtrlString(SP_DEATCH_CHANNEL, hChannel->channelId, nullptr, 0); in FreeChannelOpeate()
444 thisClass->ChannelSendSessionCtrlMsg(ctrl, hChannel->targetSessionId); in FreeChannelOpeate()
446 HChannel hChannel = (HChannel)handle->data; in FreeChannelOpeate() local
447 HdcChannelBase *thisClass = (HdcChannelBase *)hChannel->clsChannel; in FreeChannelOpeate()
448 if (!hChannel->childCleared) { in FreeChannelOpeate()
452 thisClass->FreeChannelContinue(hChannel); in FreeChannelOpeate()
454 Base::TimerUvTask(thisClass->loopMain, hChannel, callbackCheckFreeChannelContinue); in FreeChannelOpeate()
456 thisClass->FreeChannelContinue(hChannel); in FreeChannelOpeate()
467 HChannel hChannel = AdminChannel(OP_QUERY, channelId, nullptr); in FreeChannel() local
469 if (!hChannel || hChannel->isDead) { in FreeChannel()
473 Base::TimerUvTask(loopMain, hChannel, FreeChannelOpeate, MINOR_TIMEOUT); // do immediately in FreeChannel()
474 hChannel->isDead = true; in FreeChannel()
520 void HdcChannelBase::EchoToClient(HChannel hChannel, uint8_t *bufPtr, const int size) in EchoToClient() argument
534 sendStream = (uv_stream_t *)&hChannel->hChildWorkTCP; in EchoToClient()
536 ++hChannel->ref; in EchoToClient()
539 WRITE_LOG(LOG_WARN, "EchoToClient, channelId:%u is unwritable.", hChannel->channelId); in EchoToClient()
547 HChannel hChannel = (HChannel)v.second; in EchoToAllChannelsViaSessionId() local
548 if (!hChannel->isDead && hChannel->targetSessionId == targetSessionId) { in EchoToAllChannelsViaSessionId()
550 EchoToClient(hChannel, (uint8_t *)echo.c_str(), echo.size()); in EchoToAllChannelsViaSessionId()