Lines Matching refs:ctx
46 HCtxForward ctx = iter->second; in StopTask() local
47 ctxs.push_back(ctx); in StopTask()
52 for (auto ctx: ctxs) { in StopTask() local
53 FreeContext(ctx, 0, false); in StopTask()
118 HCtxForward ctx = nullptr; in MallocContext() local
119 if ((ctx = new ContextForward()) == nullptr) { in MallocContext()
122 ctx->id = Base::GetRuntimeMSec(); in MallocContext()
123 ctx->masterSlave = masterSlave; in MallocContext()
124 ctx->thisClass = this; in MallocContext()
125 ctx->fdClass = nullptr; in MallocContext()
126 ctx->tcp.data = ctx; in MallocContext()
127 ctx->pipe.data = ctx; in MallocContext()
128 AdminContext(OP_ADD, ctx->id, ctx); in MallocContext()
130 return ctx; in MallocContext()
133 void HdcForwardBase::FreeContextCallBack(HCtxForward ctx) in FreeContextCallBack() argument
135 Base::DoNextLoop(loopTask, ctx, [this](const uint8_t flag, string &msg, const void *data) { in FreeContextCallBack()
136 HCtxForward ctx = (HCtxForward)data; in FreeContextCallBack() local
137 AdminContext(OP_REMOVE, ctx->id, nullptr); in FreeContextCallBack()
138 if (ctx != nullptr) { in FreeContextCallBack()
139 WRITE_LOG(LOG_DEBUG, "Finally to delete id:%u", ctx->id); in FreeContextCallBack()
140 delete ctx; in FreeContextCallBack()
141 ctx = nullptr; in FreeContextCallBack()
149 void HdcForwardBase::FreeJDWP(HCtxForward ctx) in FreeJDWP() argument
151 Base::CloseFd(ctx->fd); in FreeJDWP()
152 if (ctx->fdClass) { in FreeJDWP()
153 ctx->fdClass->StopWorkOnThread(false, nullptr); in FreeJDWP()
157 HCtxForward ctx = (HCtxForward)handle->data; in FreeJDWP() local
158 ctx->thisClass->FreeContextCallBack(ctx); in FreeJDWP()
168 Base::IdleUvTask(loopTask, ctx, funcReqClose); in FreeJDWP()
176 HCtxForward ctx = nullptr; in FreeContext() local
178 if (!(ctx = (HCtxForward)AdminContext(OP_QUERY, id, nullptr))) { in FreeContext()
183 ctx = ctxIn; in FreeContext()
185 if (ctx->finish) { in FreeContext()
189 SendToTask(ctx->id, CMD_FORWARD_FREE_CONTEXT, nullptr, 0); in FreeContext()
192 HCtxForward ctx = (HCtxForward)handle->data; in FreeContext() local
193 ctx->thisClass->FreeContextCallBack(ctx); in FreeContext()
195 switch (ctx->type) { in FreeContext()
199 Base::TryCloseHandle((uv_handle_t *)&ctx->tcp, true, funcHandleClose); in FreeContext()
204 Base::TryCloseHandle((uv_handle_t *)&ctx->pipe, true, funcHandleClose); in FreeContext()
207 FreeJDWP(ctx); in FreeContext()
213 ctx->finish = true; in FreeContext()
256 HCtxForward ctx = (HCtxForward)stream->data; in ReadForwardBuf() local
258 WRITE_LOG(LOG_INFO, "ReadForwardBuf nread:%zd id:%u", nread, ctx->id); in ReadForwardBuf()
259 ctx->thisClass->FreeContext(ctx, 0, true); in ReadForwardBuf()
264 WRITE_LOG(LOG_INFO, "ReadForwardBuf nread:0 id:%u", ctx->id); in ReadForwardBuf()
268 ctx->thisClass->SendToTask(ctx->id, CMD_FORWARD_DATA, (uint8_t *)buf->base, nread); in ReadForwardBuf()
275 HCtxForward ctx = (HCtxForward)connection->data; in ConnectTarget() local
276 HdcForwardBase *thisClass = ctx->thisClass; in ConnectTarget()
284 thisClass->SetupPointContinue(ctx, status); in ConnectTarget()
313 bool HdcForwardBase::SetupPointContinue(HCtxForward ctx, int status) in SetupPointContinue() argument
315 if (ctx->checkPoint) { in SetupPointContinue()
318 SendToTask(ctx->id, CMD_FORWARD_CHECK_RESULT, &flag, 1); in SetupPointContinue()
319 FreeContext(ctx, 0, false); in SetupPointContinue()
323 FreeContext(ctx, 0, true); in SetupPointContinue()
327 if (!SendToTask(ctx->id, CMD_FORWARD_ACTIVE_MASTER, nullptr, 0)) { in SetupPointContinue()
328 WRITE_LOG(LOG_FATAL, "SetupPointContinue SendToTask failed id:%u", ctx->id); in SetupPointContinue()
329 FreeContext(ctx, 0, true); in SetupPointContinue()
332 return DoForwardBegin(ctx); in SetupPointContinue()
402 HCtxForward ctx = (HCtxForward)a; in SetupDevicePoint() local
403 return SendToTask(ctx->id, CMD_FORWARD_DATA, b, c); in SetupDevicePoint()
406 HCtxForward ctx = (HCtxForward)a; in SetupDevicePoint() local
407 WRITE_LOG(LOG_DEBUG, "funcFinish id:%u ret:%d reason:%s", ctx->id, b, c.c_str()); in SetupDevicePoint()
408 FreeContext(ctx, 0, true); in SetupDevicePoint()
655 bool HdcForwardBase::DoForwardBegin(HCtxForward ctx) in DoForwardBegin() argument
657 switch (ctx->type) { in DoForwardBegin()
660 uv_tcp_nodelay((uv_tcp_t *)&ctx->tcp, 1); in DoForwardBegin()
661 uv_read_start((uv_stream_t *)&ctx->tcp, AllocForwardBuf, ReadForwardBuf); in DoForwardBegin()
664 WRITE_LOG(LOG_DEBUG, "DoForwardBegin ark socketpair id:%u fds[0]:%d", ctx->id, fds[0]); in DoForwardBegin()
665 uv_tcp_init(loopTask, &ctx->tcp); in DoForwardBegin()
666 uv_tcp_open(&ctx->tcp, fds[0]); in DoForwardBegin()
667 uv_tcp_nodelay((uv_tcp_t *)&ctx->tcp, 1); in DoForwardBegin()
668 uv_read_start((uv_stream_t *)&ctx->tcp, AllocForwardBuf, ReadForwardBuf); in DoForwardBegin()
673 uv_read_start((uv_stream_t *)&ctx->pipe, AllocForwardBuf, ReadForwardBuf); in DoForwardBegin()
676 ctx->fdClass->StartWorkOnThread(); in DoForwardBegin()
682 ctx->ready = true; in DoForwardBegin()
717 HCtxForward ctx = reinterpret_cast<HCtxForward>(ctxIO->ctxForward); in SendCallbackForwardBuf() local
718 if (status < 0 && !ctx->finish) { in SendCallbackForwardBuf()
719 … WRITE_LOG(LOG_DEBUG, "SendCallbackForwardBuf ctx->type:%d, status:%d finish", ctx->type, status); in SendCallbackForwardBuf()
720 ctx->thisClass->FreeContext(ctx, 0, true); in SendCallbackForwardBuf()
727 int HdcForwardBase::SendForwardBuf(HCtxForward ctx, uint8_t *bufPtr, const int size) in SendForwardBuf() argument
743 if (ctx->type == FORWARD_DEVICE) { in SendForwardBuf()
744 nRet = ctx->fdClass->WriteWithMem(pDynBuf, size); in SendForwardBuf()
751 ctxIO->ctxForward = ctx; in SendForwardBuf()
753 if (ctx->type == FORWARD_TCP || ctx->type == FORWARD_JDWP || ctx->type == FORWARD_ARK) { in SendForwardBuf()
754 nRet = Base::SendToStreamEx((uv_stream_t *)&ctx->tcp, pDynBuf, size, nullptr, in SendForwardBuf()
758 nRet = Base::SendToStreamEx((uv_stream_t *)&ctx->pipe, pDynBuf, size, nullptr, in SendForwardBuf()
765 bool HdcForwardBase::CommandForwardCheckResult(HCtxForward ctx, uint8_t *payload) in CommandForwardCheckResult() argument
773 ctx->ready = true; in CommandForwardCheckResult()
778 FreeContext(ctx, 0, false); in CommandForwardCheckResult()
789 HCtxForward ctx = nullptr; in ForwardCommandDispatch() local
792 if (!(ctx = (HCtxForward)AdminContext(OP_QUERY, id, nullptr))) { in ForwardCommandDispatch()
798 ret = CommandForwardCheckResult(ctx, pContent); in ForwardCommandDispatch()
802 ret = DoForwardBegin(ctx); in ForwardCommandDispatch()
806 if (ctx->finish) { in ForwardCommandDispatch()
809 if (SendForwardBuf(ctx, pContent, sizeContent) < 0) { in ForwardCommandDispatch()
810 FreeContext(ctx, 0, true); in ForwardCommandDispatch()
815 FreeContext(ctx, 0, false); in ForwardCommandDispatch()
823 if (ctx) { in ForwardCommandDispatch()
824 FreeContext(ctx, 0, true); in ForwardCommandDispatch()