Browse Source

Merge pull request #1987 from slingamn/go_upgrade

upgrade go to 1.19
tags/v2.11.0-rc1
Shivaram Lingamneni 1 year ago
parent
commit
507dc2d838
No account linked to committer's email address
10 changed files with 23 additions and 49 deletions
  1. 1
    1
      .github/workflows/build.yml
  2. 1
    1
      Dockerfile
  3. 1
    1
      go.mod
  4. 1
    1
      irc/getters.go
  5. 3
    2
      irc/server.go
  6. 3
    1
      irc/smtp/smtp.go
  7. 7
    6
      irc/socket.go
  8. 0
    33
      irc/utils/config.go
  9. 1
    1
      irc/utils/proxy.go
  10. 5
    2
      irc/utils/text.go

+ 1
- 1
.github/workflows/build.yml View File

@@ -19,7 +19,7 @@ jobs:
19 19
       - name: "setup go"
20 20
         uses: "actions/setup-go@v2"
21 21
         with:
22
-          go-version: "1.18"
22
+          go-version: "1.19"
23 23
       - name: "install python3-pytest"
24 24
         run: "sudo apt install -y python3-pytest"
25 25
       - name: "make install"

+ 1
- 1
Dockerfile View File

@@ -1,5 +1,5 @@
1 1
 ## build ergo binary
2
-FROM golang:1.18-alpine AS build-env
2
+FROM golang:1.19-alpine AS build-env
3 3
 
4 4
 RUN apk add -U --force-refresh --no-cache --purge --clean-protected -l -u make git
5 5
 

+ 1
- 1
go.mod View File

@@ -1,6 +1,6 @@
1 1
 module github.com/ergochat/ergo
2 2
 
3
-go 1.18
3
+go 1.19
4 4
 
5 5
 require (
6 6
 	code.cloudfoundry.org/bytefmt v0.0.0-20200131002437-cf55d5288a48

+ 1
- 1
irc/getters.go View File

@@ -16,7 +16,7 @@ import (
16 16
 )
17 17
 
18 18
 func (server *Server) Config() (config *Config) {
19
-	return server.config.Get()
19
+	return server.config.Load()
20 20
 }
21 21
 
22 22
 func (server *Server) ChannelRegistrationEnabled() bool {

+ 3
- 2
irc/server.go View File

@@ -15,6 +15,7 @@ import (
15 15
 	"strconv"
16 16
 	"strings"
17 17
 	"sync"
18
+	"sync/atomic"
18 19
 	"syscall"
19 20
 	"time"
20 21
 
@@ -66,7 +67,7 @@ type Server struct {
66 67
 	channels          ChannelManager
67 68
 	channelRegistry   ChannelRegistry
68 69
 	clients           ClientManager
69
-	config            utils.ConfigStore[Config]
70
+	config            atomic.Pointer[Config]
70 71
 	configFilename    string
71 72
 	connectionLimiter connection_limits.Limiter
72 73
 	ctime             time.Time
@@ -707,7 +708,7 @@ func (server *Server) applyConfig(config *Config) (err error) {
707 708
 	config.Server.Cloaks.SetSecret(LoadCloakSecret(server.store))
708 709
 
709 710
 	// activate the new config
710
-	server.config.Set(config)
711
+	server.config.Store(config)
711 712
 
712 713
 	// load [dk]-lines, registered users and channels, etc.
713 714
 	if initial {

+ 3
- 1
irc/smtp/smtp.go View File

@@ -4,15 +4,17 @@
4 4
 
5 5
 // Package smtp implements the Simple Mail Transfer Protocol as defined in RFC 5321.
6 6
 // It also implements the following extensions:
7
+//
7 8
 //	8BITMIME  RFC 1652
8 9
 //	AUTH      RFC 2554
9 10
 //	STARTTLS  RFC 3207
11
+//
10 12
 // Additional extensions may be handled by clients.
11 13
 //
12 14
 // The smtp package is frozen and is not accepting new features.
13 15
 // Some external packages provide more functionality. See:
14 16
 //
15
-//   https://godoc.org/?q=smtp
17
+//	https://godoc.org/?q=smtp
16 18
 package smtp
17 19
 
18 20
 import (

+ 7
- 6
irc/socket.go View File

@@ -105,12 +105,13 @@ func (socket *Socket) Write(data []byte) (err error) {
105 105
 }
106 106
 
107 107
 // BlockingWrite sends the given string out of Socket. Requirements:
108
-// 1. MUST block until the message is sent
109
-// 2. MUST bypass sendq (calls to BlockingWrite cannot, on their own, cause a sendq overflow)
110
-// 3. MUST provide mutual exclusion for socket.conn.Write
111
-// 4. MUST respect the same ordering guarantees as Write (i.e., if a call to Write that sends
112
-//    message m1 happens-before a call to BlockingWrite that sends message m2,
113
-//    m1 must be sent on the wire before m2
108
+//  1. MUST block until the message is sent
109
+//  2. MUST bypass sendq (calls to BlockingWrite cannot, on their own, cause a sendq overflow)
110
+//  3. MUST provide mutual exclusion for socket.conn.Write
111
+//  4. MUST respect the same ordering guarantees as Write (i.e., if a call to Write that sends
112
+//     message m1 happens-before a call to BlockingWrite that sends message m2,
113
+//     m1 must be sent on the wire before m2
114
+//
114 115
 // Callers MUST be writing to the client's socket from the client's own goroutine;
115 116
 // other callers must use the nonblocking Write call instead. Otherwise, a client
116 117
 // with a slow/unreliable connection risks stalling the progress of the system as a whole.

+ 0
- 33
irc/utils/config.go View File

@@ -1,33 +0,0 @@
1
-// Copyright (c) 2022 Shivaram Lingamneni
2
-// released under the MIT license
3
-
4
-package utils
5
-
6
-import (
7
-	"sync/atomic"
8
-	"unsafe"
9
-)
10
-
11
-/*
12
-This can be used to implement the following pattern:
13
-
14
-1. Prepare a config object (this can be arbitrarily expensive)
15
-2. Take a pointer to the config object and use Set() to install it
16
-3. Use Get() to access the config from any goroutine
17
-4. To update the config, call Set() again with a new prepared config object
18
-5. As long as any individual config object is not modified (by any goroutine)
19
-   after it is installed with Set(), this is free of data races, and Get()
20
-   is extremely cheap (on amd64 it compiles down to plain MOV instructions).
21
-*/
22
-
23
-type ConfigStore[Config any] struct {
24
-	ptr unsafe.Pointer
25
-}
26
-
27
-func (c *ConfigStore[Config]) Get() *Config {
28
-	return (*Config)(atomic.LoadPointer(&c.ptr))
29
-}
30
-
31
-func (c *ConfigStore[Config]) Set(ptr *Config) {
32
-	atomic.StorePointer(&c.ptr, unsafe.Pointer(ptr))
33
-}

+ 1
- 1
irc/utils/proxy.go View File

@@ -203,7 +203,7 @@ func parseProxyLineV2(line []byte) (ip net.IP, err error) {
203 203
 	return ip, nil
204 204
 }
205 205
 
206
-/// WrappedConn is a net.Conn with some additional data stapled to it;
206
+// / WrappedConn is a net.Conn with some additional data stapled to it;
207 207
 // the proxied IP, if one was read via the PROXY protocol, and the listener
208 208
 // configuration.
209 209
 type WrappedConn struct {

+ 5
- 2
irc/utils/text.go View File

@@ -22,9 +22,12 @@ type MessagePair struct {
22 22
 // SplitMessage represents a message that's been split for sending.
23 23
 // Two possibilities:
24 24
 // (a) Standard message that can be relayed on a single 512-byte line
25
-//     (MessagePair contains the message, Split == nil)
25
+//
26
+//	(MessagePair contains the message, Split == nil)
27
+//
26 28
 // (b) multiline message that was split on the client side
27
-//     (Message == "", Split contains the split lines)
29
+//
30
+//	(Message == "", Split contains the split lines)
28 31
 type SplitMessage struct {
29 32
 	Message string
30 33
 	Msgid   string

Loading…
Cancel
Save