@@ -509,17 +509,13 @@ type Config struct {
509
509
510
510
serverInitOnce sync.Once // guards calling (*Config).serverInit
511
511
512
- // mutex protects sessionTicketKeys and originalConfig .
512
+ // mutex protects sessionTicketKeys.
513
513
mutex sync.RWMutex
514
514
// sessionTicketKeys contains zero or more ticket keys. If the length
515
515
// is zero, SessionTicketsDisabled must be true. The first key is used
516
516
// for new tickets and any subsequent keys can be used to decrypt old
517
517
// tickets.
518
518
sessionTicketKeys []ticketKey
519
- // originalConfig is set to the Config that was passed to Server if
520
- // this Config is returned by a GetConfigForClient callback. It's used
521
- // by serverInit in order to copy session ticket keys if needed.
522
- originalConfig * Config
523
519
}
524
520
525
521
// ticketKeyNameLen is the number of bytes of identifier that is prepended to
@@ -551,7 +547,7 @@ func ticketKeyFromBytes(b [32]byte) (key ticketKey) {
551
547
func (c * Config ) Clone () * Config {
552
548
// Running serverInit ensures that it's safe to read
553
549
// SessionTicketsDisabled.
554
- c .serverInitOnce .Do (c .serverInit )
550
+ c .serverInitOnce .Do (func () { c .serverInit ( nil ) } )
555
551
556
552
var sessionTicketKeys []ticketKey
557
553
c .mutex .RLock ()
@@ -585,20 +581,17 @@ func (c *Config) Clone() *Config {
585
581
Renegotiation : c .Renegotiation ,
586
582
KeyLogWriter : c .KeyLogWriter ,
587
583
sessionTicketKeys : sessionTicketKeys ,
588
- // originalConfig is deliberately not duplicated.
589
584
}
590
585
}
591
586
592
- func (c * Config ) serverInit () {
587
+ // serverInit is run under c.serverInitOnce to do initialization of c. If c was
588
+ // returned by a GetConfigForClient callback then the argument should be the
589
+ // Config that was passed to Server, otherwise it should be nil.
590
+ func (c * Config ) serverInit (originalConfig * Config ) {
593
591
if c .SessionTicketsDisabled || len (c .ticketKeys ()) != 0 {
594
592
return
595
593
}
596
594
597
- var originalConfig * Config
598
- c .mutex .Lock ()
599
- originalConfig , c .originalConfig = c .originalConfig , nil
600
- c .mutex .Unlock ()
601
-
602
595
alreadySet := false
603
596
for _ , b := range c .SessionTicketKey {
604
597
if b != 0 {
0 commit comments