MCPcopy Create free account
hub / github.com/amule-project/amule / SendPacket

Method SendPacket

src/EMSocket.cpp:329–363  ·  view source on GitHub ↗

* 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

Source from the content-addressed store, hash-verified

327 * @return true if the packet was added to the queue, false otherwise
328 */
329void 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
366uint64 CEMSocket::GetSentBytesCompleteFileSinceLastCallAndReset()

Callers 15

SendBlockRequestsMethod · 0.45
UDPReaskForDownloadMethod · 0.45
SendListToServerMethod · 0.45
NextPacketToSocketMethod · 0.45
StartNewSearchMethod · 0.45
GetLogMethod · 0.45
AddServerMethod · 0.45
BootstrapKadMethod · 0.45
UpdateNotesDatMethod · 0.45
SendToRemoteMethod · 0.45
RemoveCatMethod · 0.45
ConnectToAnyServerMethod · 0.45

Calls 3

GetTickCount64Function · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected