Browse Source

fix #1969

On a 32-bit architecture, 64-bit atomic loads and stores must be aligned to a
64-bit boundary. Since the (mysql.MySQL) struct is directly included in the
Server struct, it is impossible to guarantee this via the standard technique
of putting the 64-bit value at the beginning of the struct definition
(since the point at which it is included in the parent struct may cross a
64-bit boundary).

This optimization is probably pointless anyway, adding an additional
indirection won't make a difference.
tags/v2.11.0-rc1
Shivaram Lingamneni 1 year ago
parent
commit
69448b13a1
1 changed files with 4 additions and 3 deletions
  1. 4
    3
      irc/mysql/history.go

+ 4
- 3
irc/mysql/history.go View File

@@ -45,7 +45,7 @@ const (
45 45
 type e struct{}
46 46
 
47 47
 type MySQL struct {
48
-	timeout              int64
48
+	timeout              *int64
49 49
 	trackAccountMessages uint32
50 50
 	db                   *sql.DB
51 51
 	logger               *logger.Manager
@@ -63,13 +63,14 @@ type MySQL struct {
63 63
 }
64 64
 
65 65
 func (mysql *MySQL) Initialize(logger *logger.Manager, config Config) {
66
+	mysql.timeout = new(int64)
66 67
 	mysql.logger = logger
67 68
 	mysql.wakeForgetter = make(chan e, 1)
68 69
 	mysql.SetConfig(config)
69 70
 }
70 71
 
71 72
 func (mysql *MySQL) SetConfig(config Config) {
72
-	atomic.StoreInt64(&mysql.timeout, int64(config.Timeout))
73
+	atomic.StoreInt64(mysql.timeout, int64(config.Timeout))
73 74
 	var trackAccountMessages uint32
74 75
 	if config.TrackAccountMessages {
75 76
 		trackAccountMessages = 1
@@ -554,7 +555,7 @@ func (mysql *MySQL) prepareStatements() (err error) {
554 555
 }
555 556
 
556 557
 func (mysql *MySQL) getTimeout() time.Duration {
557
-	return time.Duration(atomic.LoadInt64(&mysql.timeout))
558
+	return time.Duration(atomic.LoadInt64(mysql.timeout))
558 559
 }
559 560
 
560 561
 func (mysql *MySQL) isTrackingAccountMessages() bool {

Loading…
Cancel
Save