summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlfred Persson Forsberg <cat@catcream.org>2023-04-05 20:38:35 +0200
committerSam James <sam@gentoo.org>2023-04-10 03:51:54 +0100
commitdf056a8be36b580156a0d198e1a141efdb5a2dd7 (patch)
tree4c1af305a6f4b0317879841694c094b72ff0ca7c /net-irc
parentnet-irc/soju: add USE=pam for pam auth support (diff)
downloadgentoo-df056a8be36b580156a0d198e1a141efdb5a2dd7.tar.gz
gentoo-df056a8be36b580156a0d198e1a141efdb5a2dd7.tar.bz2
gentoo-df056a8be36b580156a0d198e1a141efdb5a2dd7.zip
net-irc/soju: add patch for dup upstream connections
https://todo.sr.ht/~emersion/soju/207 Signed-off-by: Alfred Persson Forsberg <cat@catcream.org> Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'net-irc')
-rw-r--r--net-irc/soju/files/soju-0.6.0-fix-dup-upstream-connections.patch69
-rw-r--r--net-irc/soju/soju-0.6.0.ebuild4
2 files changed, 73 insertions, 0 deletions
diff --git a/net-irc/soju/files/soju-0.6.0-fix-dup-upstream-connections.patch b/net-irc/soju/files/soju-0.6.0-fix-dup-upstream-connections.patch
new file mode 100644
index 000000000000..ca1f0fdf41c7
--- /dev/null
+++ b/net-irc/soju/files/soju-0.6.0-fix-dup-upstream-connections.patch
@@ -0,0 +1,69 @@
+https://todo.sr.ht/~emersion/soju/207
+
+diff -u b/user.go b/user.go
+--- b/user.go
++++ b/user.go
+@@ -218,6 +218,7 @@
+ net.user.srv.metrics.upstreams.Add(1)
+ defer net.user.srv.metrics.upstreams.Add(-1)
+
++ done := ctx.Done()
+ ctx, cancel := context.WithTimeout(ctx, time.Minute)
+ defer cancel()
+
+@@ -227,6 +228,12 @@
+ }
+ defer uc.Close()
+
++ // The context is cancelled by the caller when the network is stopped.
++ go func() {
++ <-done
++ uc.Close()
++ }()
++
+ if net.user.srv.Identd != nil {
+ net.user.srv.Identd.Store(uc.RemoteAddr().String(), uc.LocalAddr().String(), userIdent(&net.user.User))
+ defer net.user.srv.Identd.Delete(uc.RemoteAddr().String(), uc.LocalAddr().String())
+@@ -239,9 +246,6 @@
+ return fmt.Errorf("failed to register: %w", err)
+ }
+
+- // TODO: this is racy with net.stopped. If the network is stopped
+- // before the user goroutine receives eventUpstreamConnected, the
+- // connection won't be closed.
+ net.user.events <- eventUpstreamConnected{uc}
+ defer func() {
+ net.user.events <- eventUpstreamDisconnected{uc}
+@@ -259,6 +263,12 @@
+ return
+ }
+
++ ctx, cancel := context.WithCancel(context.TODO())
++ go func() {
++ <-net.stopped
++ cancel()
++ }()
++
+ var lastTry time.Time
+ backoff := newBackoffer(retryConnectMinDelay, retryConnectMaxDelay, retryConnectJitter)
+ for {
+@@ -273,7 +283,7 @@
+ }
+ lastTry = time.Now()
+
+- if err := net.runConn(context.TODO()); err != nil {
++ if err := net.runConn(ctx); err != nil {
+ text := err.Error()
+ temp := true
+ var regErr registrationError
+@@ -299,10 +309,6 @@
+ if !net.isStopped() {
+ close(net.stopped)
+ }
+-
+- if net.conn != nil {
+- net.conn.Close()
+- }
+ }
+
+ func (net *network) detach(ch *database.Channel) {
diff --git a/net-irc/soju/soju-0.6.0.ebuild b/net-irc/soju/soju-0.6.0.ebuild
index 6a410939fdc3..cec8de059876 100644
--- a/net-irc/soju/soju-0.6.0.ebuild
+++ b/net-irc/soju/soju-0.6.0.ebuild
@@ -24,6 +24,10 @@ RDEPEND="
"
DEPEND="${RDEPEND}"
+PATCHES=(
+ "${FILESDIR}"/${PN}-0.6.0-fix-dup-upstream-connections.patch
+)
+
src_compile() {
GOFLAGS+=" -tags=moderncsqlite"
use pam && GOFLAGS+=" -tags=pam"