Skip to content

Commit

Permalink
add memmove api count for send
Browse files Browse the repository at this point in the history
  • Loading branch information
kibaamor committed Nov 3, 2021
1 parent bc92f78 commit 0672877
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions examples/echo_conn.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class echo_conn : public conn {
<< ", send:" << s.send_count
<< ", write:" << s.write_count
<< ", copy:" << s.copy_count
<< ", move:" << s.move_count
<< ", recv:" << s.read_count
<< ", read:" << s.read_count
<< "\n";
Expand Down
9 changes: 5 additions & 4 deletions include/knet/kconn.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class conn {
struct stat {
uint32_t send_count = 0; // send_data
uint32_t write_count = 0; // writev
uint32_t copy_count = 0; // memcpy
uint32_t copy_count = 0; // memcpy for send
uint32_t move_count = 0; // memmove for send

uint32_t recv_count = 0; // on_recv_data
uint32_t read_count = 0; // read
Expand Down Expand Up @@ -49,9 +50,9 @@ class conn {
protected:
bool set_sockbuf_size(size_t size);

virtual void do_on_connected() {}
virtual void do_on_disconnect() {}
virtual void do_on_timer(int64_t ms, const userdata& ud) {}
virtual void do_on_connected() { }
virtual void do_on_disconnect() { }
virtual void do_on_timer(int64_t ms, const userdata& ud) { }
virtual size_t do_on_recv_data(char* data, size_t size) = 0;

private:
Expand Down
5 changes: 5 additions & 0 deletions src/internal/socket/ksocket_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,11 @@ bool socket::impl::handle_read()
}
if (size > 0) {
_rb->discard_used((std::min)(size, max_size));
#ifdef KNET_SOCKET_STAT
if (_rb->used_size) {
KNET_SOCKET_STAT_CODE(++_stat.move_count)
}
#endif // KNET_SOCKET_STAT
}

return true;
Expand Down
5 changes: 5 additions & 0 deletions src/internal/socket/ksocket_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,11 @@ bool socket::impl::handle_read(size_t size)
}
if (size > 0) {
_rb->discard_used((std::min)(size, max_size));
#ifdef KNET_SOCKET_STAT
if (_rb->used_size) {
KNET_SOCKET_STAT_CODE(++_stat.move_count)
}
#endif // KNET_SOCKET_STAT
}

return true;
Expand Down

0 comments on commit 0672877

Please sign in to comment.