Skip to content

Commit

Permalink
V6 backports (#1986)
Browse files Browse the repository at this point in the history
Backporting commits:

* 8b31858 :  Portability: remove explicit check for libdl
* dd3292c : Refactor peerRefreshDNS() to clarify its (void*)1 logic
* 0ef767a: Nil request dereference in
           ACLExtUser and SourceDomainCheck ACLs
  • Loading branch information
kinkie authored and squid-anubis committed Jan 30, 2025
1 parent f90523e commit c220319
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 21 deletions.
8 changes: 0 additions & 8 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -393,14 +393,6 @@ AS_IF([test "x$squid_opt_aufs_threads" != "x"],[
[Defines how many threads aufs uses for I/O])
])

## TODO check if this is necessary, LT_INIT does these checks
SQUID_AUTO_LIB(dl,[dynamic linking],[LIBDL])
AS_IF([test "x$with_dl" != "xno"],[
CXXFLAGS="$LIBDL_CFLAGS $CXXFLAGS"
LDFLAGS="$LIBDL_PATH $LDFLAGS"
AC_CHECK_LIB(dl, dlopen)
])

AC_DEFUN([LIBATOMIC_CHECKER],[
AC_MSG_CHECKING(whether linking $1 -latomic works)
AC_LINK_IFELSE([
Expand Down
1 change: 1 addition & 0 deletions src/acl/ExtUser.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class ACLExtUser : public ACL
char const *typeString() const override;
void parse() override;
int match(ACLChecklist *checklist) override;
bool requiresRequest() const override { return true; }
SBufList dump() const override;
bool empty () const override;

Expand Down
6 changes: 5 additions & 1 deletion src/acl/SourceDomain.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ SourceDomainLookup::LookupDone(const char *, const Dns::LookupDetails &details,
{
ACLFilledChecklist *checklist = Filled((ACLChecklist*)data);
checklist->markSourceDomainChecked();
checklist->request->recordLookup(details);
if (checklist->request)
checklist->request->recordLookup(details);
else
debugs(28, 3, "no request to recordLookup()");

checklist->resumeNonBlockingCheck(SourceDomainLookup::Instance());
}

Expand Down
33 changes: 21 additions & 12 deletions src/neighbors.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ static void neighborAlive(CachePeer *, const MemObject *, const icp_common_t *);
static void neighborAliveHtcp(CachePeer *, const MemObject *, const HtcpReplyData *);
#endif
static void neighborCountIgnored(CachePeer *);
static void peerRefreshDNS(void *);
static void peerDnsRefreshCheck(void *);
static void peerDnsRefreshStart();
static IPH peerDNSConfigure;
static void peerProbeConnect(CachePeer *, const bool reprobeIfBusy = false);
static CNCB peerProbeConnectDone;
Expand Down Expand Up @@ -583,7 +584,7 @@ neighbors_init(void)
}
}

peerRefreshDNS((void *) 1);
peerDnsRefreshStart();

sep = getservbyname("echo", "udp");
echo_port = sep ? ntohs((unsigned short) sep->s_port) : 7;
Expand Down Expand Up @@ -1237,24 +1238,32 @@ peerDNSConfigure(const ipcache_addrs *ia, const Dns::LookupDetails &, void *data
}

static void
peerRefreshDNS(void *data)
peerScheduleDnsRefreshCheck(const double delayInSeconds)
{
CachePeer *p = nullptr;

if (eventFind(peerRefreshDNS, nullptr))
eventDelete(peerRefreshDNS, nullptr);
if (eventFind(peerDnsRefreshCheck, nullptr))
eventDelete(peerDnsRefreshCheck, nullptr);
eventAddIsh("peerDnsRefreshCheck", peerDnsRefreshCheck, nullptr, delayInSeconds, 1);
}

if (!data && 0 == stat5minClientRequests()) {
static void
peerDnsRefreshCheck(void *)
{
if (!stat5minClientRequests()) {
/* no recent client traffic, wait a bit */
eventAddIsh("peerRefreshDNS", peerRefreshDNS, nullptr, 180.0, 1);
peerScheduleDnsRefreshCheck(180.0);
return;
}

for (p = Config.peers; p; p = p->next)
peerDnsRefreshStart();
}

static void
peerDnsRefreshStart()
{
for (auto p = Config.peers; p; p = p->next)
ipcache_nbgethostbyname(p->host, peerDNSConfigure, p);

/* Reconfigure the peers every hour */
eventAddIsh("peerRefreshDNS", peerRefreshDNS, nullptr, 3600.0, 1);
peerScheduleDnsRefreshCheck(3600.0);
}

/// whether new TCP probes are currently banned
Expand Down

0 comments on commit c220319

Please sign in to comment.