Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 apt-cacher-ng (3.3.1-1) unstable; urgency=medium
 .
   * Bugfix upstream release update
     + (CVE-2020-5202) Enforce secured call to the server in maint job triggering
     + Allow .zst compression for tarballs (closes: Bug#948259, thanks
       to Arnaud Rebillout)
     + Added branch information to Vcs-Git control line (closes: #913594)
     + Hint about not set (by debconf) CacheDir variable in zz_debconf.conf
       (closes: #929031)
Author: Eduard Bloch <blade@debian.org>
Bug-Debian: https://bugs.debian.org/913594
Bug-Debian: https://bugs.debian.org/929031
Bug-Debian: https://bugs.debian.org/948259

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: 2020-01-08

--- apt-cacher-ng-3.3.1.orig/ChangeLog
+++ apt-cacher-ng-3.3.1/ChangeLog
@@ -17,10 +17,8 @@ apt-cacher-ng (3.3.1) A-LITTLE-BUGFIX-FO
         environment variable
   * Support .zst compressed packages (reference:
     https://www.archlinux.org/news/now-using-zstandard-instead-of-xz-for-package-compression/ )
-  * Added global cancelation points for the daemon shutdown phase, now
-    terminating sooner especially when a maintenance jobs runs in background
 
- -- Eduard Bloch <blade@debian.org>  Wed, 08 Jan 2020 20:47:37 +0100
+ -- Eduard Bloch <blade@debian.org>  Tue, 07 Jan 2020 21:33:24 +0100
 
 apt-cacher-ng (3.3) THE-CLAMPS-ARE-MARCHING; urgency=low
 
--- apt-cacher-ng-3.3.1.orig/VERSION
+++ apt-cacher-ng-3.3.1/VERSION
@@ -1 +1 @@
-3.3.1
+3.3
--- apt-cacher-ng-3.3.1.orig/include/evabase.h
+++ apt-cacher-ng-3.3.1/include/evabase.h
@@ -21,7 +21,6 @@ class ACNG_API evabase
 
 public:
 	event_base *base;
-	static std::atomic<bool> in_shutdown;
 	/** Share the global instance created by main() */
 	static std::shared_ptr<evabase> instance;
 	evabase();
--- apt-cacher-ng-3.3.1.orig/source/apt-cacher.cc
+++ apt-cacher-ng-3.3.1/source/apt-cacher.cc
@@ -237,7 +237,6 @@ void term_handler(evutil_socket_t signum
 	case (SIGINT):
 	case (SIGQUIT):
 	{
-		evabase::in_shutdown.store(true);
 		if(evabase::instance)
 			event_base_loopbreak(evabase::instance->base);
 		break;
--- apt-cacher-ng-3.3.1.orig/source/bgtask.cc
+++ apt-cacher-ng-3.3.1/source/bgtask.cc
@@ -12,7 +12,6 @@
 #include "acfg.h"
 #include "meta.h"
 #include "filereader.h"
-#include "evabase.h"
 
 #include <limits.h>
 #include <errno.h>
@@ -285,7 +284,7 @@ void tSpecOpDetachable::Run()
 bool tSpecOpDetachable::CheckStopSignal()
 {
 	lockguard g(&g_StateCv);
-	return g_sigTaskAbort || evabase::in_shutdown;
+	return g_sigTaskAbort;
 }
 
 void tSpecOpDetachable::DumpLog(time_t id)
--- apt-cacher-ng-3.3.1.orig/source/dlcon.cc
+++ apt-cacher-ng-3.3.1/source/dlcon.cc
@@ -14,7 +14,6 @@
 #include "fileitem.h"
 #include "fileio.h"
 #include "sockio.h"
-#include "evabase.h"
 
 #ifdef HAVE_LINUX_EVENTFD
 #include <sys/eventfd.h>
@@ -722,17 +721,18 @@ inline void dlcon::wake()
 	}
 
 }
-
-void ACNG_API dlcon::awaken_check()
+inline void dlcon::awaken_check()
 {
+	LOGSTART("dlcon::awaken_check");
 	eventfd_t xtmp;
-	for(int i=0; i < 1000 ; ++i)
+	for(int i=0; ; ++i)
 	{
 		auto tmp = eventfd_read(fdWakeRead, &xtmp);
-		if(tmp == 0)
-			return;
-		if(errno != EAGAIN)
-			return;
+		LOG("got one event, res: " << tmp << ", errno: " << errno);
+		if(i > 100) // breakpoint... OS bug? what's the errno?
+			break;
+		if(tmp == -1 && errno == EAGAIN) continue;
+		break;
 	}
 }
 
@@ -763,7 +763,7 @@ bool dlcon::AddJob(tFileItemPtr m_pItem,
 			return false;
 	}
 	setLockGuard;
-	if(m_bStopASAP || evabase::in_shutdown)
+	if(m_bStopASAP)
 		return false;
 /*
 	ASSERT(
@@ -859,7 +859,7 @@ inline unsigned dlcon::ExchangeData(mstr
 
 		r=select(nMaxFd + 1, &rfds, &wfds, nullptr, CTimeVal().ForNetTimeout());
 		ldbg("returned: " << r << ", errno: " << errno);
-		if(m_bStopASAP || evabase::in_shutdown)
+		if(m_bStopASAP)
 		{
 			return HINT_DISCON;
 		}
@@ -1176,7 +1176,7 @@ void dlcon::WorkLoop()
         	setLockGuard;
         	LOG("New jobs: " << m_qNewjobs.size());
 
-        	if(m_bStopASAP || evabase::in_shutdown)
+        	if(m_bStopASAP)
         	{
         		/* The no-more-users checking logic will purge orphaned items from the inpipe
         		 * queue. When the connection is dirty after that, it will be closed in the
@@ -1363,7 +1363,7 @@ void dlcon::WorkLoop()
         // inner loop: plain communication until something happens. Maybe should use epoll here?
         loopRes=ExchangeData(sErrorMsg, con, inpipe);
         ldbg("loopRes: "<< loopRes);
-        if(m_bStopASAP || evabase::in_shutdown)
+        if(m_bStopASAP)
         	return;
 
         /* check whether we have a pipeline stall. This may happen because a) we are done or
--- apt-cacher-ng-3.3.1.orig/source/evabase.cc
+++ apt-cacher-ng-3.3.1/source/evabase.cc
@@ -15,7 +15,6 @@ namespace acng
 {
 
 std::shared_ptr<evabase> evabase::instance;
-std::atomic<bool> evabase::in_shutdown = ATOMIC_VAR_INIT(false);
 
 evabase::evabase() : base (event_base_new())
 {
--- apt-cacher-ng-3.3.1.orig/source/tcpconnect.cc
+++ apt-cacher-ng-3.3.1/source/tcpconnect.cc
@@ -20,7 +20,6 @@
 #include "fileitem.h"
 #include "cleaner.h"
 #include "dnsiter.h"
-#include "evabase.h"
 #include <tuple>
 
 using namespace std;
@@ -297,8 +296,6 @@ inline bool tcpconnect::_Connect(string
 		}
 
 		auto res = select(selset.nfds(), nullptr, &selset.fds, nullptr, tv.Remaining(time_inter));
-		if(evabase::in_shutdown)
-			return withThisErrno(ETIMEDOUT);
 		if (res < 0)
 		{
 			if (EINTR != errno)
