Skip to content

Commit

Permalink
fcgi/SConnection: inline all StockItem wrapper functions
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKellermann committed Feb 25, 2025
1 parent ada0cfb commit c0eef5e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 49 deletions.
39 changes: 1 addition & 38 deletions src/fcgi/SConnection.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ FcgiStockConnection::FcgiStockConnection(CreateStockItem c, ListenChildStockItem
{
}

inline void
void
FcgiStockConnection::SetAborted() noexcept
{
if (fresh)
Expand Down Expand Up @@ -73,40 +73,3 @@ FcgiStockConnection::~FcgiStockConnection() noexcept
{
event.Close();
}

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

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

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

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

return connection->GetSocket();
}

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

connection->SetAborted();
}
44 changes: 33 additions & 11 deletions src/fcgi/SConnection.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,37 @@ private:
void OnSocketEvent(unsigned events) noexcept;
};

void
fcgi_stock_item_set_site(StockItem &item, const char *site) noexcept;

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

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

/**
* Returns the socket descriptor of the specified stock item.
*/
SocketDescriptor
fcgi_stock_item_get(const StockItem &item) noexcept;
static inline SocketDescriptor
fcgi_stock_item_get(const StockItem &item) noexcept
{
const auto *connection = (const FcgiStockConnection *)&item;

return connection->GetSocket();
}

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

/**
* Let the fcgi_stock know that the client is being aborted. The
Expand All @@ -97,5 +114,10 @@ fcgi_stock_item_get_stderr(const StockItem &item) noexcept;
* release the process - fcgi_stock_put() stil needs to be called
* after this function.
*/
void
fcgi_stock_aborted(StockItem &item) noexcept;
static inline void
fcgi_stock_aborted(StockItem &item) noexcept
{
auto *connection = (FcgiStockConnection *)&item;

connection->SetAborted();
}

0 comments on commit c0eef5e

Please sign in to comment.