Skip to content

Commit aff43d5

Browse files
author
Michael Bleis
committed
Merge branch 'master' of github.com:an-tao/trantor
2 parents 4b7557b + 14471b5 commit aff43d5

File tree

17 files changed

+71
-34
lines changed

17 files changed

+71
-34
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules/)
1414

1515
set(TRANTOR_MAJOR_VERSION 1)
1616
set(TRANTOR_MINOR_VERSION 5)
17-
set(TRANTOR_PATCH_VERSION 22)
17+
set(TRANTOR_PATCH_VERSION 23)
1818
set(TRANTOR_VERSION ${TRANTOR_MAJOR_VERSION}.${TRANTOR_MINOR_VERSION}.${TRANTOR_PATCH_VERSION})
1919

2020
include(GNUInstallDirs)

ChangeLog.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
## [1.5.23] - 2025-02-20
8+
9+
### Changed
10+
11+
- Replace ipv4 inet_ntop with a handrolled function.
12+
13+
### Fixed
14+
15+
- Fix some typos.
16+
717
## [1.5.22] - 2024-10-27
818

919
### Fixed
@@ -686,7 +696,9 @@ All notable changes to this project will be documented in this file.
686696

687697
## [1.0.0-rc1] - 2019-06-11
688698

689-
[Unreleased]: https://github.com/an-tao/trantor/compare/v1.5.22...HEAD
699+
[Unreleased]: https://github.com/an-tao/trantor/compare/v1.5.23...HEAD
700+
701+
[1.5.23]: https://github.com/an-tao/trantor/compare/v1.5.22...v1.5.23
690702

691703
[1.5.22]: https://github.com/an-tao/trantor/compare/v1.5.21...v1.5.22
692704

third_party/wepoll/Wepoll.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,7 @@ int init(void)
902902
/* `InitOnceExecuteOnce()` itself is infallible, and it doesn't set any
903903
* error code when the once-callback returns FALSE. We return -1 here to
904904
* indicate that global initialization failed; the failing init function
905-
* is resposible for setting `errno` and calling `SetLastError()`. */
905+
* is responsible for setting `errno` and calling `SetLastError()`. */
906906
return -1;
907907

908908
return 0;

trantor/net/EventLoop.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ using ssize_t = long long;
4545
#include <algorithm>
4646
#include <signal.h>
4747
#include <fcntl.h>
48+
#include <exception>
4849

4950
namespace trantor
5051
{

trantor/net/EventLoop.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ enum
4545

4646
/**
4747
* @brief As the name implies, this class represents an event loop that runs in
48-
* a perticular thread. The event loop can handle network I/O events and timers
48+
* a particular thread. The event loop can handle network I/O events and timers
4949
* in asynchronous mode.
5050
* @note An event loop object always belongs to a separate thread, and there is
5151
* one event loop object at most in a thread. We can call an event loop object

trantor/net/InetAddress.cc

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,16 +196,40 @@ bool InetAddress::isLoopbackIp() const
196196
return false;
197197
}
198198

199+
static void byteToChars(std::string::iterator &dst, unsigned char byte)
200+
{
201+
*dst = byte / 100 + '0';
202+
dst += byte >= 100;
203+
*dst = byte % 100 / 10 + '0';
204+
dst += byte >= 10;
205+
*dst = byte % 10 + '0';
206+
++dst;
207+
}
208+
209+
static std::string iptos(unsigned inet_addr)
210+
{
211+
// Initialize with a static buffer to force the constructor of string to get
212+
// fully inlined
213+
constexpr char stringInitBuffer[15]{};
214+
std::string out(stringInitBuffer, 15);
215+
std::string::iterator dst = out.begin();
216+
byteToChars(dst, inet_addr >> 0 & 0xff);
217+
*(dst++) = '.';
218+
byteToChars(dst, inet_addr >> 8 & 0xff);
219+
*(dst++) = '.';
220+
byteToChars(dst, inet_addr >> 16 & 0xff);
221+
*(dst++) = '.';
222+
byteToChars(dst, inet_addr >> 24 & 0xff);
223+
out.erase(dst, out.end());
224+
return out;
225+
}
226+
199227
std::string InetAddress::toIp() const
200228
{
201-
char buf[64];
229+
char buf[INET6_ADDRSTRLEN]{};
202230
if (addr_.sin_family == AF_INET)
203231
{
204-
#if defined _WIN32
205-
::inet_ntop(AF_INET, (PVOID)&addr_.sin_addr, buf, sizeof(buf));
206-
#else
207-
::inet_ntop(AF_INET, &addr_.sin_addr, buf, sizeof(buf));
208-
#endif
232+
return iptos(addr_.sin_addr.s_addr);
209233
}
210234
else if (addr_.sin_family == AF_INET6)
211235
{

trantor/net/InetAddress.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ class TRANTOR_EXPORT InetAddress
219219
}
220220

221221
/**
222-
* @brief Return true if the address is not initalized.
222+
* @brief Return true if the address is not initialized.
223223
*/
224224
inline bool isUnspecified() const
225225
{

trantor/net/inner/Acceptor.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ void Acceptor::readCallback()
8383
}
8484
else
8585
{
86-
LOG_SYSERR << "Accpetor::readCallback";
86+
LOG_SYSERR << "Acceptor::readCallback";
8787
// Read the section named "The special problem of
8888
// accept()ing when you can't" in libev's doc.
8989
// By Marc Lehmann, author of libev.

trantor/net/inner/poller/EpollPoller.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const int kDeleted = 2;
5353
EpollPoller::EpollPoller(EventLoop *loop)
5454
: Poller(loop),
5555
#ifdef _WIN32
56-
// wepoll does not suppor flags
56+
// wepoll does not support flags
5757
epollfd_(::epoll_create1(0)),
5858
#else
5959
epollfd_(::epoll_create1(EPOLL_CLOEXEC)),
@@ -85,7 +85,7 @@ void EpollPoller::poll(int timeoutMs, ChannelList *activeChannels)
8585
// Timestamp now(Timestamp::now());
8686
if (numEvents > 0)
8787
{
88-
// LOG_TRACE << numEvents << " events happended";
88+
// LOG_TRACE << numEvents << " events happened";
8989
fillActiveChannels(numEvents, activeChannels);
9090
if (static_cast<size_t>(numEvents) == events_.size())
9191
{
@@ -94,7 +94,7 @@ void EpollPoller::poll(int timeoutMs, ChannelList *activeChannels)
9494
}
9595
else if (numEvents == 0)
9696
{
97-
// std::cout << "nothing happended" << std::endl;
97+
// std::cout << "nothing happened" << std::endl;
9898
}
9999
else
100100
{

trantor/net/inner/poller/KQueue.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void KQueue::poll(int timeoutMs, ChannelList *activeChannels)
5959
// Timestamp now(Timestamp::now());
6060
if (numEvents > 0)
6161
{
62-
// LOG_TRACE << numEvents << " events happended";
62+
// LOG_TRACE << numEvents << " events happened";
6363
fillActiveChannels(numEvents, activeChannels);
6464
if (static_cast<size_t>(numEvents) == events_.size())
6565
{
@@ -68,7 +68,7 @@ void KQueue::poll(int timeoutMs, ChannelList *activeChannels)
6868
}
6969
else if (numEvents == 0)
7070
{
71-
// std::cout << "nothing happended" << std::endl;
71+
// std::cout << "nothing happened" << std::endl;
7272
}
7373
else
7474
{

0 commit comments

Comments
 (0)