| 684 | } |
| 685 | |
| 686 | static void DoraXrtHttpStreamOnRecv(ptr owner, xnetstream* stream, xnetchain* chain) { |
| 687 | DoraXrtHttpStreamContext* ctx = (DoraXrtHttpStreamContext*)owner; |
| 688 | size_t len; |
| 689 | char* data; |
| 690 | (void)stream; |
| 691 | if (!ctx || !chain || __xnetAtomicLoad32(&ctx->closeRequested) != 0) { |
| 692 | return; |
| 693 | } |
| 694 | len = xrtNetChainBytes(chain); |
| 695 | if (len == 0u) { |
| 696 | return; |
| 697 | } |
| 698 | data = (char*)malloc(len); |
| 699 | if (!data) { |
| 700 | DoraXrtHttpStreamCloseWith(ctx, XRT_NET_ERROR); |
| 701 | return; |
| 702 | } |
| 703 | if (xrtNetChainPeek(chain, data, len) != len) { |
| 704 | free(data); |
| 705 | DoraXrtHttpStreamCloseWith(ctx, XRT_NET_ERROR); |
| 706 | return; |
| 707 | } |
| 708 | xrtNetChainConsume(chain, len); |
| 709 | if (!DoraXrtHttpStreamAppend(ctx, data, len)) { |
| 710 | free(data); |
| 711 | DoraXrtHttpStreamCloseWith(ctx, XRT_NET_ERROR); |
| 712 | return; |
| 713 | } |
| 714 | free(data); |
| 715 | (void)DoraXrtHttpStreamProcess(ctx); |
| 716 | } |
| 717 | |
| 718 | static void DoraXrtHttpStreamOnClose(ptr owner, xnetstream* stream, xnet_result reason) { |
| 719 | DoraXrtHttpStreamContext* ctx = (DoraXrtHttpStreamContext*)owner; |
nothing calls this directly
no test coverage detected