Skip to content

Commit

Permalink
fcgi/Connection: rename to FcgiStockConnection
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKellermann committed Jan 15, 2025
1 parent 2198d01 commit feec983
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/fcgi/Request.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "Request.hxx"
#include "Stock.hxx"
#include "Connection.hxx"
#include "SConnection.hxx"
#include "Client.hxx"
#include "http/PendingRequest.hxx"
#include "http/ResponseHandler.hxx"
Expand Down
28 changes: 14 additions & 14 deletions src/fcgi/Connection.cxx → src/fcgi/SConnection.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
// Copyright CM4all GmbH
// author: Max Kellermann <mk@cm4all.com>

#include "Connection.hxx"
#include "SConnection.hxx"
#include "net/UniqueSocketDescriptor.hxx"

#include <errno.h>
#include <string.h>

FcgiConnection::FcgiConnection(CreateStockItem c, ListenChildStockItem &_child,
UniqueSocketDescriptor &&socket) noexcept
FcgiStockConnection::FcgiStockConnection(CreateStockItem c, ListenChildStockItem &_child,
UniqueSocketDescriptor &&socket) noexcept
:StockItem(c), logger(GetStockName()),
child(_child),
event(GetStock().GetEventLoop(), BIND_THIS_METHOD(OnSocketEvent),
Expand All @@ -20,14 +20,14 @@ FcgiConnection::FcgiConnection(CreateStockItem c, ListenChildStockItem &_child,
}

inline void
FcgiConnection::SetAborted() noexcept
FcgiStockConnection::SetAborted() noexcept
{
if (fresh)
child.Fade();
}

inline void
FcgiConnection::Read() noexcept
FcgiStockConnection::Read() noexcept
{
std::byte buffer[1];
ssize_t nbytes = GetSocket().ReadNoWait(buffer);
Expand All @@ -38,14 +38,14 @@ FcgiConnection::Read() noexcept
}

inline void
FcgiConnection::OnSocketEvent(unsigned) noexcept
FcgiStockConnection::OnSocketEvent(unsigned) noexcept
{
Read();
InvokeIdleDisconnect();
}

bool
FcgiConnection::Borrow() noexcept
FcgiStockConnection::Borrow() noexcept
{
if (event.GetReadyFlags() != 0) [[unlikely]] {
/* this connection was probably closed, but our
Expand All @@ -62,51 +62,51 @@ FcgiConnection::Borrow() noexcept
}

bool
FcgiConnection::Release() noexcept
FcgiStockConnection::Release() noexcept
{
fresh = false;
defer_schedule_read.ScheduleIdle();
return true;
}

FcgiConnection::~FcgiConnection() noexcept
FcgiStockConnection::~FcgiStockConnection() noexcept
{
event.Close();
}

UniqueFileDescriptor
fcgi_stock_item_get_stderr(const StockItem &item) noexcept
{
const auto &connection = (const FcgiConnection &)item;
const auto &connection = (const FcgiStockConnection &)item;
return connection.GetStderr();
}

void
fcgi_stock_item_set_site(StockItem &item, const char *site) noexcept
{
auto &connection = (FcgiConnection &)item;
auto &connection = (FcgiStockConnection &)item;
connection.SetSite(site);
}

void
fcgi_stock_item_set_uri(StockItem &item, const char *uri) noexcept
{
auto &connection = (FcgiConnection &)item;
auto &connection = (FcgiStockConnection &)item;
connection.SetUri(uri);
}

SocketDescriptor
fcgi_stock_item_get(const StockItem &item) noexcept
{
const auto *connection = (const FcgiConnection *)&item;
const auto *connection = (const FcgiStockConnection *)&item;

return connection->GetSocket();
}

void
fcgi_stock_aborted(StockItem &item) noexcept
{
auto *connection = (FcgiConnection *)&item;
auto *connection = (FcgiStockConnection *)&item;

connection->SetAborted();
}
8 changes: 4 additions & 4 deletions src/fcgi/Connection.hxx → src/fcgi/SConnection.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

class UniqueSocketDescriptor;

class FcgiConnection final : public StockItem {
class FcgiStockConnection final : public StockItem {
const LLogger logger;

ListenChildStockItem &child;
Expand All @@ -33,10 +33,10 @@ class FcgiConnection final : public StockItem {
bool fresh = true;

public:
explicit FcgiConnection(CreateStockItem c, ListenChildStockItem &_child,
UniqueSocketDescriptor &&socket) noexcept;
explicit FcgiStockConnection(CreateStockItem c, ListenChildStockItem &_child,
UniqueSocketDescriptor &&socket) noexcept;

~FcgiConnection() noexcept override;
~FcgiStockConnection() noexcept override;

[[gnu::pure]]
std::string_view GetTag() const noexcept {
Expand Down
6 changes: 3 additions & 3 deletions src/fcgi/Stock.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// author: Max Kellermann <mk@cm4all.com>

#include "Stock.hxx"
#include "Connection.hxx"
#include "SConnection.hxx"
#include "Error.hxx"
#include "stock/Stock.hxx"
#include "stock/Class.hxx"
Expand Down Expand Up @@ -189,7 +189,7 @@ FcgiStock::CreateRequest::OnStockItemReady(StockItem &item) noexcept
auto &child = static_cast<ListenChildStockItem &>(item);

try {
auto *connection = new FcgiConnection(create, child, child.Connect());
auto *connection = new FcgiStockConnection(create, child, child.Connect());
connection->InvokeCreateSuccess(handler);
} catch (...) {
child.Put(PutAction::DESTROY);
Expand Down Expand Up @@ -224,7 +224,7 @@ FcgiStock::Create(CreateStockItem c, StockItem &shared_item)
auto &child = (ListenChildStockItem &)shared_item;

try {
return new FcgiConnection(c, child, child.Connect());
return new FcgiStockConnection(c, child, child.Connect());
} catch (...) {
std::throw_with_nested(FcgiClientError(FcgiClientErrorCode::REFUSED,
FmtBuffer<256>("Failed to connect to FastCGI server {:?}",
Expand Down
2 changes: 1 addition & 1 deletion src/fcgi/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fcgi_stock = static_library(
'Remote.cxx',
'Request.cxx',
'Stock.cxx',
'Connection.cxx',
'SConnection.cxx',
include_directories: inc,
dependencies: [
fcgi_client_dep,
Expand Down

0 comments on commit feec983

Please sign in to comment.