MCPcopy Create free account
hub / github.com/MariaDB/server / net_write_buff

Function net_write_buff

sql/net_serv.cc:570–618  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

568*/
569
570static my_bool
571net_write_buff(NET *net, const uchar *packet, size_t len)
572{
573 size_t left_length;
574 if (net->compress && net->max_packet > MAX_PACKET_LENGTH)
575 left_length= (MAX_PACKET_LENGTH - (net->write_pos - net->buff));
576 else
577 left_length= (net->buff_end - net->write_pos);
578
579#ifdef DEBUG_DATA_PACKETS
580 DBUG_DUMP("data_written", packet, len);
581#endif
582 if (len > left_length)
583 {
584 if (net->write_pos != net->buff)
585 {
586 /* Fill up already used packet and write it */
587 memcpy((char*) net->write_pos,packet,left_length);
588 if (net_real_write(net, net->buff,
589 (size_t) (net->write_pos - net->buff) + left_length))
590 return 1;
591 net->write_pos= net->buff;
592 packet+= left_length;
593 len-= left_length;
594 }
595 if (net->compress)
596 {
597 /*
598 We can't have bigger packets than 16M with compression
599 Because the uncompressed length is stored in 3 bytes
600 */
601 left_length= MAX_PACKET_LENGTH;
602 while (len > left_length)
603 {
604 if (net_real_write(net, packet, left_length))
605 return 1;
606 packet+= left_length;
607 len-= left_length;
608 }
609 }
610 if (len > net->max_packet)
611 return net_real_write(net, packet, len) ? 1 : 0;
612 /* Send out rest of the blocks as full sized blocks */
613 }
614 if (len)
615 memcpy((char*) net->write_pos,packet,len);
616 net->write_pos+= len;
617 return 0;
618}
619
620
621/**

Callers 2

my_net_writeFunction · 0.85
net_write_commandFunction · 0.85

Calls 1

net_real_writeFunction · 0.85

Tested by

no test coverage detected