Przeglądaj źródła

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 rok temu
rodzic
commit
69448b13a1
1 zmienionych plików z 4 dodań i 3 usunięć
  1. 4
    3
      irc/mysql/history.go

+ 4
- 3
irc/mysql/history.go Wyświetl plik

45
 type e struct{}
45
 type e struct{}
46
 
46
 
47
 type MySQL struct {
47
 type MySQL struct {
48
-	timeout              int64
48
+	timeout              *int64
49
 	trackAccountMessages uint32
49
 	trackAccountMessages uint32
50
 	db                   *sql.DB
50
 	db                   *sql.DB
51
 	logger               *logger.Manager
51
 	logger               *logger.Manager
63
 }
63
 }
64
 
64
 
65
 func (mysql *MySQL) Initialize(logger *logger.Manager, config Config) {
65
 func (mysql *MySQL) Initialize(logger *logger.Manager, config Config) {
66
+	mysql.timeout = new(int64)
66
 	mysql.logger = logger
67
 	mysql.logger = logger
67
 	mysql.wakeForgetter = make(chan e, 1)
68
 	mysql.wakeForgetter = make(chan e, 1)
68
 	mysql.SetConfig(config)
69
 	mysql.SetConfig(config)
69
 }
70
 }
70
 
71
 
71
 func (mysql *MySQL) SetConfig(config Config) {
72
 func (mysql *MySQL) SetConfig(config Config) {
72
-	atomic.StoreInt64(&mysql.timeout, int64(config.Timeout))
73
+	atomic.StoreInt64(mysql.timeout, int64(config.Timeout))
73
 	var trackAccountMessages uint32
74
 	var trackAccountMessages uint32
74
 	if config.TrackAccountMessages {
75
 	if config.TrackAccountMessages {
75
 		trackAccountMessages = 1
76
 		trackAccountMessages = 1
554
 }
555
 }
555
 
556
 
556
 func (mysql *MySQL) getTimeout() time.Duration {
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
 func (mysql *MySQL) isTrackingAccountMessages() bool {
561
 func (mysql *MySQL) isTrackingAccountMessages() bool {

Ładowanie…
Anuluj
Zapisz