| 906 | |
| 907 | public: |
| 908 | void SendRequestImpl(const TConnectionAddress& addr, const TString& url, TVector<char>* data, const TGUID& reqId, |
| 909 | TWaitResponse* wr, TRequesterUserQueues* userQueues) { |
| 910 | if (data && data->size() > MAX_PACKET_SIZE) { |
| 911 | Y_ABORT_UNLESS(0, "data size is too large"); |
| 912 | } |
| 913 | //printf("SendRequest(%s)\n", url.c_str()); |
| 914 | if (wr) |
| 915 | wr->SetReqId(reqId); |
| 916 | |
| 917 | TVector<char> flags(4 * 2 + 2 + 1); |
| 918 | (i16&)flags[0] = (i16)addr.GetResponseDataTos(); |
| 919 | (i16&)flags[2] = (i16)addr.GetResponseAckTos(); |
| 920 | (i16&)flags[4] = (i16)addr.GetRequestDataTos(); |
| 921 | (i16&)flags[6] = (i16)addr.GetRequestAckTos(); |
| 922 | (ui8&)flags[8] = addr.GetNetlibaRequestColor(); |
| 923 | (ui8&)flags[9] = addr.GetNetlibaResponseColor(); |
| 924 | if (addr.GetPriority() == PP_HIGH) { |
| 925 | (ui8&)flags[10] = HF_HP_QUEUE; |
| 926 | } |
| 927 | |
| 928 | TAutoPtr<TRopeDataPacket> ms = new TRopeDataPacket; |
| 929 | if (data && data->ysize() > MIN_SHARED_MEM_PACKET && Host->IsLocal(addr.GetAddress())) { |
| 930 | int dataSize = data->ysize(); |
| 931 | TIntrusivePtr<TPosixSharedMemory> shm = new TPosixSharedMemory; |
| 932 | if (shm->Create(dataSize)) { |
| 933 | ms->Write((char)PKT_LOCAL_REQUEST); |
| 934 | ms->Write(reqId); |
| 935 | ms->WriteDestructive(&flags); |
| 936 | ms->WriteStroka(url); |
| 937 | memcpy(shm->GetPtr(), &(*data)[0], dataSize); |
| 938 | TVector<char> empty; |
| 939 | data->swap(empty); |
| 940 | ms->AttachSharedData(shm); |
| 941 | } |
| 942 | } |
| 943 | |
| 944 | if (ms->GetSharedData() == nullptr) { |
| 945 | ms->Write((char)PKT_REQUEST); |
| 946 | ms->Write(reqId); |
| 947 | ms->WriteDestructive(&flags); |
| 948 | ms->WriteStroka(url); |
| 949 | ms->WriteDestructive(data); |
| 950 | } |
| 951 | |
| 952 | SendReqList.Enqueue(new TSendRequest(addr, &ms, reqId, wr, userQueues)); |
| 953 | Host->CancelWait(); |
| 954 | } |
| 955 | |
| 956 | void SendRequest(const TConnectionAddress& addr, const TString& url, TVector<char>* data, const TGUID& reqId) override { |
| 957 | SendRequestImpl(addr, url, data, reqId, nullptr, UserQueues.Get()); |
no test coverage detected