GS to Customer single package and m_quegcwait (all GC sharing)

Source: Internet
Author: User

GS to the customer single package and m_quegcwait (all GC sharing) Send_stat Basechannel::sendcmd (intNcmd,void* PData,intNlen)    {Protocol Ptl; Ptl.cmd_type=Ncmd; Ptl.content=PData; Ptl.size=Nlen; void* Tmpbuffer =ms_psendbuff2c; if(Nlen >__gc_max_send_buff_len) {Shuihu::getlogger ()->fatal (""%s (line%d)" Critical error, sending cmd=%d packet, packet length (%d) greater than maximum send packet (%d)", __function__, __line__, Ncmd, Nlen, __gc_max_send_buff_len); Safe::error_msg ("The GC Send packet length is too long! "); }    intNSize = Ptl.to_buffer (Tmpbuffer, __gc_max_send_buff_len);//Pack to Tmpbuffer    if(-1==nSize)returnSend_stat::send_parameter_error;    DATAPKT Pkt; //There is a problem with the memory pool, join the shared memory has not come out, this memory will run out sooner or later, there is a buffer queue good advantage is not sent out you can go back to do other things, wait for the next time to send//so there's a need to reallocate memory to save the package content, and the benefit of the memory pool is the duplicate New,delete//I looked at his pop, and if he's finished, he's new again, that's about it, or he's going to have to wait for Duzi.Pkt.pdata = M_PSHARE->POPPKT (nSize);//allocating a chunk of memory to the GC shared memory poolPkt.nsize =nSize;    memcpy (Pkt.pdata, Tmpbuffer, nSize); M_quecmd.push (Pkt);//sent to the command buffer    returnsendcmdtry ();} Send_stat basechannel::sendcmdtry ()//It 's the only way to say that every GC sends a packet, and he tries to send it all the rest of the packets.{    if(!m_quecmd.size ())returnSend_stat::send_succeed;  for(;;) {        if(M_quecmd.empty ()) Break; DATAPKT PKT=M_quecmd.front (); {Send_stat hr= M_pdatalayer->senddata (M_nchannelid, Pkt.pdata, pkt.nsize);//Send to Network layer            if(HR! = send_stat::send_succeed)//failed to send, indicating that the sending side of the shared memory ran out (there is a question why not make the shared memory a little bigger)            {                //put in the waiting queue, let the GS to send (there is a problem why to let GS send, send failed to return directly, the next time to send just)M_pshare->pushgcwait (M_nchannelid);//put it in all the GC shared queues that are not sent                returnhr; }} m_quecmd.pop ();//Description sent successfullyM_pshare->PUSHPKT (Pkt.pdata, pkt.nsize);//return shared Memory    }    returnsend_stat::send_succeed;}

GS to Customer single package and m_quegcwait (all GC sharing)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.