Skip to content

Commit be09eca

Browse files
trondndaverigby
authored andcommitted
Refactor: add MC::sendBuffer(cb::const_byte_buffer)
Change-Id: I132dcb81da3455eaa23d5da474823c40ecc59f56 Reviewed-on: http://review.couchbase.org/110275 Tested-by: Build Bot <[email protected]> Reviewed-by: Dave Rigby <[email protected]>
1 parent 37965e2 commit be09eca

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

protocol/connection/client_connection.cc

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -524,14 +524,7 @@ void MemcachedConnection::readPlain(Frame& frame, size_t bytes) {
524524
}
525525

526526
void MemcachedConnection::sendFrame(const Frame& frame) {
527-
if (ssl) {
528-
sendFrameSsl(frame);
529-
} else {
530-
sendFramePlain(frame);
531-
}
532-
if (packet_dump) {
533-
cb::mcbp::dump(frame.payload.data(), std::cerr);
534-
}
527+
sendBuffer({frame.payload.data(), frame.payload.size()});
535528
}
536529

537530
void MemcachedConnection::sendBuffer(const std::vector<iovec>& list) {
@@ -555,6 +548,21 @@ void MemcachedConnection::sendBuffer(const std::vector<iovec>& list) {
555548
}
556549
}
557550

551+
void MemcachedConnection::sendBuffer(cb::const_byte_buffer buf) {
552+
if (packet_dump) {
553+
try {
554+
cb::mcbp::dumpStream(buf, std::cerr);
555+
} catch (const std::exception&) {
556+
// ignore..
557+
}
558+
}
559+
if (ssl) {
560+
sendBufferSsl(buf);
561+
} else {
562+
sendBufferPlain(buf);
563+
}
564+
}
565+
558566
void MemcachedConnection::sendPartialFrame(Frame& frame,
559567
Frame::size_type length) {
560568
// Move the remainder to a new frame.

protocol/connection/client_connection.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -820,17 +820,8 @@ class MemcachedConnection {
820820

821821
void readSsl(Frame& frame, size_t bytes);
822822

823-
void sendFramePlain(const Frame& frame) {
824-
sendBufferPlain(cb::const_byte_buffer(frame.payload.data(),
825-
frame.payload.size()));
826-
}
827-
828-
void sendFrameSsl(const Frame& frame) {
829-
sendBufferSsl(cb::const_byte_buffer(frame.payload.data(),
830-
frame.payload.size()));
831-
}
832-
833823
void sendBuffer(const std::vector<iovec>& buf);
824+
void sendBuffer(cb::const_byte_buffer buf);
834825

835826
void sendBufferPlain(cb::const_byte_buffer buf);
836827
void sendBufferPlain(const std::vector<iovec>& list);

0 commit comments

Comments
 (0)