Skip to content

Commit

Permalink
修复sql_debug没有发送消息终结符的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
hnwyllmm committed Oct 19, 2023
1 parent e1019fa commit 4b816f7
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/observer/net/plain_communicator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ RC PlainCommunicator::write_state(SessionEvent *event, bool &need_disconnect)
snprintf(buf, buf_size, "%s > %s\n", strrc(sql_result->return_code()), state_string.c_str());
}

RC rc = writer_->writen(buf, strlen(buf) + 1);
RC rc = writer_->writen(buf, strlen(buf));
if (OB_FAIL(rc)) {
LOG_WARN("failed to send data to client. err=%s", strerror(errno));
need_disconnect = true;
Expand Down Expand Up @@ -159,7 +159,18 @@ RC PlainCommunicator::write_result(SessionEvent *event, bool &need_disconnect)
{
RC rc = write_result_internal(event, need_disconnect);
if (!need_disconnect) {
(void)write_debug(event, need_disconnect);
RC rc1 = write_debug(event, need_disconnect);
if (OB_FAIL(rc1)) {
LOG_WARN("failed to send debug info to client. rc=%s, err=%s", strrc(rc), strerror(errno));
}
}
if (!need_disconnect) {
rc = writer_->writen(send_message_delimiter_.data(), send_message_delimiter_.size());
if (OB_FAIL(rc)) {
LOG_ERROR("Failed to send data back to client. ret=%s, error=%s", strrc(rc), strerror(errno));
need_disconnect = true;
return rc;
}
}
writer_->flush(); // TODO handle error
return rc;
Expand Down Expand Up @@ -276,14 +287,6 @@ RC PlainCommunicator::write_result_internal(SessionEvent *event, bool &need_disc
sql_result->set_return_code(rc);
return write_state(event, need_disconnect);
} else {

rc = writer_->writen(send_message_delimiter_.data(), send_message_delimiter_.size());
if (OB_FAIL(rc)) {
LOG_ERROR("Failed to send data back to client. ret=%s, error=%s", strrc(rc), strerror(errno));
sql_result->close();
return rc;
}

need_disconnect = false;
}

Expand Down

0 comments on commit 4b816f7

Please sign in to comment.