Spaces:
Paused
Paused
xukc commited on
Commit ·
506d0f7
1
Parent(s): 090b129
[fix]log fmt err
Browse files- tcp_inbound.cpp +5 -5
tcp_inbound.cpp
CHANGED
|
@@ -18,13 +18,13 @@ class TcpClientShell {
|
|
| 18 |
cli.onConnection = [this](const hv::SocketChannelPtr& channel) {
|
| 19 |
std::string peeraddr = channel->peeraddr();
|
| 20 |
if (channel->isConnected()) {
|
| 21 |
-
spdlog::info("connected to {
|
| 22 |
if (wait_send_buf.getDataSize() > 0)
|
| 23 |
{
|
| 24 |
cli.send(wait_send_buf.getData(), wait_send_buf.getDataSize());
|
| 25 |
}
|
| 26 |
} else {
|
| 27 |
-
spdlog::info("disconnected to {
|
| 28 |
hio_close(io);
|
| 29 |
}
|
| 30 |
};
|
|
@@ -62,12 +62,12 @@ class TcpClientShell {
|
|
| 62 |
};
|
| 63 |
|
| 64 |
static void tcp_on_close(hio_t* io) {
|
| 65 |
-
spdlog::info("tcp_on_close fd={
|
| 66 |
ConnMap<hio_t*, TcpClientShell>::getInstance().remove(io);
|
| 67 |
}
|
| 68 |
|
| 69 |
static void tcp_on_recv(hio_t* io, void* buf, int readbytes) {
|
| 70 |
-
spdlog::info("tcp_on_recv fd={
|
| 71 |
hio_write(io, buf, readbytes);
|
| 72 |
auto cli = ConnMap<hio_t*, TcpClientShell>::getInstance().get(io);
|
| 73 |
if(cli) {
|
|
@@ -80,7 +80,7 @@ void tcp_on_accept(hio_t* io, hevent_t* ev) {
|
|
| 80 |
|
| 81 |
char localaddrstr[SOCKADDR_STRLEN] = {0};
|
| 82 |
char peeraddrstr[SOCKADDR_STRLEN] = {0};
|
| 83 |
-
spdlog::info("tcp_on_accept tid=
|
| 84 |
(long)hv_gettid(),
|
| 85 |
(int)hio_fd(io),
|
| 86 |
SOCKADDR_STR(hio_localaddr(io), localaddrstr),
|
|
|
|
| 18 |
cli.onConnection = [this](const hv::SocketChannelPtr& channel) {
|
| 19 |
std::string peeraddr = channel->peeraddr();
|
| 20 |
if (channel->isConnected()) {
|
| 21 |
+
spdlog::info("connected to {}! connfd={}\n", peeraddr.c_str(), channel->fd());
|
| 22 |
if (wait_send_buf.getDataSize() > 0)
|
| 23 |
{
|
| 24 |
cli.send(wait_send_buf.getData(), wait_send_buf.getDataSize());
|
| 25 |
}
|
| 26 |
} else {
|
| 27 |
+
spdlog::info("disconnected to {}! connfd={}\n", peeraddr.c_str(), channel->fd());
|
| 28 |
hio_close(io);
|
| 29 |
}
|
| 30 |
};
|
|
|
|
| 62 |
};
|
| 63 |
|
| 64 |
static void tcp_on_close(hio_t* io) {
|
| 65 |
+
spdlog::info("tcp_on_close fd={} error={}\n", hio_fd(io), hio_error(io));
|
| 66 |
ConnMap<hio_t*, TcpClientShell>::getInstance().remove(io);
|
| 67 |
}
|
| 68 |
|
| 69 |
static void tcp_on_recv(hio_t* io, void* buf, int readbytes) {
|
| 70 |
+
spdlog::info("tcp_on_recv fd={} buf({})={}\n", hio_fd(io), readbytes, (const char*)buf);
|
| 71 |
hio_write(io, buf, readbytes);
|
| 72 |
auto cli = ConnMap<hio_t*, TcpClientShell>::getInstance().get(io);
|
| 73 |
if(cli) {
|
|
|
|
| 80 |
|
| 81 |
char localaddrstr[SOCKADDR_STRLEN] = {0};
|
| 82 |
char peeraddrstr[SOCKADDR_STRLEN] = {0};
|
| 83 |
+
spdlog::info("tcp_on_accept tid={} connfd={} [{}] <= [{}]\n",
|
| 84 |
(long)hv_gettid(),
|
| 85 |
(int)hio_fd(io),
|
| 86 |
SOCKADDR_STR(hio_localaddr(io), localaddrstr),
|