Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/SquidConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ class SquidConfig
} Addrs;
size_t tcpRcvBufsz;
size_t udpMaxHitObjsz;
wordlist *mcast_group_list;
SBufList mcast_group_list;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not add non-POD data members to SquidConfig. That class must be a POD because the global configuration object is accessed before main() starts and after main() exits1. Our NoNewGlobals policy essentially applies to SquidConfig data members. SquidConfig is already documented to be a POD. Several existing data members violate this rule and that documentation2, but we should not make the problem more difficult to fix by adding new violations.

AFAICT, the correct new type for mcast_group_list data member is a raw pointer to SBufList. Unfortunately, more code changes are required to support that new type in current code, but nothing major.

Footnotes

  1. For an example of problems caused by non-POD Config members, see recent commit c565067 that fixes one of those problems.

  2. We probably just did not know better when we added them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: SquidConfig has contained other SBufList for a year now without problems. So has already been proven safe for this particular global usage.

FTR: the issues requiring strictly POD-only members have been resolved since Squid v4 (3b1439d). Objects which use MEMPROXY allocation and are default constructable can be used, at least as members of existing globals now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue(s) behind c565067 were that values within the post initialization SSL_CTX are not global safe. The ContextPointer itself should be global-safe, but the context it was pointing to needed to be deleted explicitly at a certain timing/order.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FTR: the issues requiring strictly POD-only members have been resolved since Squid v4 (3b1439d).

The "issues" are C++ global object construction and destruction rules. They cannot be resolved without changing the language itself.

CachePeers *peers;
int npeers;

Expand Down
2 changes: 1 addition & 1 deletion src/cf.data.pre
Original file line number Diff line number Diff line change
Expand Up @@ -8753,7 +8753,7 @@ COMMENT_START
COMMENT_END

NAME: mcast_groups
TYPE: wordlist
TYPE: SBufList
LOC: Config.mcast_group_list
DEFAULT: none
DOC_START
Expand Down
6 changes: 4 additions & 2 deletions src/icp_v2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -739,8 +739,10 @@ icpIncomingConnectionOpened(Ipc::StartListeningAnswer &answer)

Comm::SetSelect(conn->fd, COMM_SELECT_READ, icpHandleUdp, nullptr, 0);

for (const wordlist *s = Config.mcast_group_list; s; s = s->next)
ipcache_nbgethostbyname(s->key, mcastJoinGroups, nullptr); // XXX: pass the conn for mcastJoinGroups usage.
for (const auto &groupName : Config.mcast_group_list) {
SBuf tmp(groupName); // XXX: c_str() may reallocate
ipcache_nbgethostbyname(tmp.c_str(), mcastJoinGroups, nullptr); // XXX: pass the conn for mcastJoinGroups usage.
}

debugs(12, DBG_IMPORTANT, "Accepting ICP messages on " << conn->local);

Expand Down
Loading