* Queues up the packet to be sent. Another thread will actually send the packet. * * If the packet is not a control packet, and if the socket decides that its queue is * full and forceAdd is false, then the socket is allowed to refuse to add the packet * to its queue. It will then return false and it is up to the calling thread to try * to call SendPacket for that packet again at a later time
| 327 | * @return true if the packet was added to the queue, false otherwise |
| 328 | */ |
| 329 | void CEMSocket::SendPacket(CPacket* packet, bool delpacket, bool controlpacket, uint32 actualPayloadSize) |
| 330 | { |
| 331 | //printf("* SendPacket called on socket %p\n", this); |
| 332 | std::lock_guard<std::mutex> lock(m_sendLocker); |
| 333 | |
| 334 | if (byConnected == ES_DISCONNECTED) { |
| 335 | //printf("* Disconnected, drop packet\n"); |
| 336 | if(delpacket) { |
| 337 | delete packet; |
| 338 | } |
| 339 | } else { |
| 340 | if (!delpacket){ |
| 341 | packet = new CPacket(*packet); |
| 342 | } |
| 343 | |
| 344 | if (controlpacket) { |
| 345 | //printf("* Adding a control packet\n"); |
| 346 | m_control_queue.push_back(packet); |
| 347 | |
| 348 | // queue up for controlpacket |
| 349 | theApp->uploadBandwidthThrottler->QueueForSendingControlPacket(this, HasSent()); |
| 350 | } else { |
| 351 | //printf("* Adding a normal packet to the queue\n"); |
| 352 | bool first = !((sendbuffer && !m_currentPacket_is_controlpacket) || !m_standard_queue.empty()); |
| 353 | StandardPacketQueueEntry queueEntry = { actualPayloadSize, packet }; |
| 354 | m_standard_queue.push_back(queueEntry); |
| 355 | |
| 356 | // reset timeout for the first time |
| 357 | if (first) { |
| 358 | lastFinishedStandard = ::GetTickCount64(); |
| 359 | m_bAccelerateUpload = true; // Always accelerate first packet in a block |
| 360 | } |
| 361 | } |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | |
| 366 | uint64 CEMSocket::GetSentBytesCompleteFileSinceLastCallAndReset() |
no test coverage detected