MCPcopy Create free account
hub / github.com/Tencent/phxsql / WriteToDest

Method WriteToDest

phxsqlproxy/io_channel.cpp:128–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126}
127
128int IOChannel::WriteToDest(int dest_fd, const char * buf, int write_size) {
129 MonitorPluginEntry::GetDefault()->GetMonitorPlugin()->WriteNetwork(write_size);
130 //for debug
131 //
132 if (config_->OpenDebugMode()) {
133 std::string debug_str;
134 GetMysqlBufDebugString(buf, write_size, debug_str);
135 LOG_DEBUG("dest %d command [%s]", dest_fd, debug_str.c_str());
136 }
137 //for debug end
138
139 int written_once = 0;
140 int total_written = 0;
141 while (total_written < write_size) {
142 written_once = RoutineWriteWithTimeout(dest_fd, buf + total_written, write_size - total_written,
143 config_->WriteTimeoutMs());
144 if (written_once < 0) {
145 LOG_ERR("write to %d buf size [%d] failed, ret %d, errno (%d:%s)",
146 dest_fd, write_size, written_once, errno, strerror(errno));
147 MonitorPluginEntry::GetDefault()->GetMonitorPlugin()->WriteNetworkFail(write_size);
148 return -__LINE__;
149 }
150 total_written += written_once;
151 }
152 return total_written;
153}
154
155int IOChannel::TransMsgDirect(int source_fd, int dest_fd, struct pollfd pf[], int nfds) {
156 int byte_size = 0;

Callers

nothing calls this directly

Calls 7

GetMysqlBufDebugStringFunction · 0.85
RoutineWriteWithTimeoutFunction · 0.85
WriteNetworkMethod · 0.80
GetMonitorPluginMethod · 0.80
OpenDebugModeMethod · 0.80
WriteTimeoutMsMethod · 0.80
WriteNetworkFailMethod · 0.80

Tested by

no test coverage detected