aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/http/server/http.cpp
diff options
context:
space:
mode:
authorwd28 <wd28@yandex-team.ru>2022-02-10 16:49:40 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:40 +0300
commit1b7466cb957659079ebebbb5d76e64e51f3306f0 (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/http/server/http.cpp
parent23df4007b6ffbbdb0b25a214dded0c60538fb558 (diff)
downloadydb-1b7466cb957659079ebebbb5d76e64e51f3306f0.tar.gz
Restoring authorship annotation for <wd28@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/http/server/http.cpp')
-rw-r--r--library/cpp/http/server/http.cpp76
1 files changed, 38 insertions, 38 deletions
diff --git a/library/cpp/http/server/http.cpp b/library/cpp/http/server/http.cpp
index 5aaf48db07..128583bdd7 100644
--- a/library/cpp/http/server/http.cpp
+++ b/library/cpp/http/server/http.cpp
@@ -326,17 +326,17 @@ public:
ErrorCode = 0;
TIntrusiveListWithAutoDelete<TListenSocket, TDelete> Reqs;
- std::function<void(TSocket)> callback = [&](TSocket socket) {
- THolder<TListenSocket> ls(new TListenSocket(socket, this));
- Poller->WaitRead(socket, static_cast<IPollAble*>(ls.Get()));
- Reqs.PushBack(ls.Release());
- };
+ std::function<void(TSocket)> callback = [&](TSocket socket) {
+ THolder<TListenSocket> ls(new TListenSocket(socket, this));
+ Poller->WaitRead(socket, static_cast<IPollAble*>(ls.Get()));
+ Reqs.PushBack(ls.Release());
+ };
bool addressesBound = TryToBindAddresses(Options_, &callback);
if (!addressesBound) {
SaveErrorCode();
- ListenStartEvent.Signal();
+ ListenStartEvent.Signal();
- return;
+ return;
}
Requests->Start(Options_.nThreads, Options_.MaxQueueSize);
@@ -795,49 +795,49 @@ bool TRequestReplier::Reply(void* threadSpecificResource) {
return DoReply(params);
}
-
+
bool TryToBindAddresses(const THttpServerOptions& options, const std::function<void(TSocket)>* callbackOnBoundAddress) {
- THttpServerOptions::TBindAddresses addrs;
+ THttpServerOptions::TBindAddresses addrs;
try {
options.BindAddresses(addrs);
} catch (const std::exception&) {
return false;
}
-
- for (const auto& na : addrs) {
- for (TNetworkAddress::TIterator ai = na.Begin(); ai != na.End(); ++ai) {
- NAddr::TAddrInfo addr(&*ai);
-
- TSocket socket(::socket(addr.Addr()->sa_family, SOCK_STREAM, 0));
-
- if (socket == INVALID_SOCKET) {
+
+ for (const auto& na : addrs) {
+ for (TNetworkAddress::TIterator ai = na.Begin(); ai != na.End(); ++ai) {
+ NAddr::TAddrInfo addr(&*ai);
+
+ TSocket socket(::socket(addr.Addr()->sa_family, SOCK_STREAM, 0));
+
+ if (socket == INVALID_SOCKET) {
return false;
- }
-
- FixIPv6ListenSocket(socket);
-
+ }
+
+ FixIPv6ListenSocket(socket);
+
if (options.ReuseAddress) {
int yes = 1;
::setsockopt(socket, SOL_SOCKET, SO_REUSEADDR, (const char*)&yes, sizeof(yes));
}
-
- if (options.ReusePort) {
- SetReusePort(socket, true);
- }
-
- if (::bind(socket, addr.Addr(), addr.Len()) == SOCKET_ERROR) {
+
+ if (options.ReusePort) {
+ SetReusePort(socket, true);
+ }
+
+ if (::bind(socket, addr.Addr(), addr.Len()) == SOCKET_ERROR) {
return false;
- }
-
- if (::listen(socket, options.ListenBacklog) == SOCKET_ERROR) {
+ }
+
+ if (::listen(socket, options.ListenBacklog) == SOCKET_ERROR) {
return false;
- }
-
+ }
+
if (callbackOnBoundAddress != nullptr) {
- (*callbackOnBoundAddress)(socket);
- }
- }
- }
-
+ (*callbackOnBoundAddress)(socket);
+ }
+ }
+ }
+
return true;
-}
+}