aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2020-01-28 15:40:52 +0100
committerSimon Ser <contact@emersion.fr>2020-01-28 15:41:18 +0100
commitc0b4998b383daf6f0990717f61bdcf557841b03e (patch)
tree3c79a4d4b536e5757e48cb18b8344511db9fe589
parent85c01b87a99233fcc273e810b4ad48bb0d33096f (diff)
downloadalps-c0b4998b383daf6f0990717f61bdcf557841b03e.tar.gz
alps-c0b4998b383daf6f0990717f61bdcf557841b03e.zip
koushin: rename Session.locker to imapLocker
-rw-r--r--session.go20
1 files changed, 10 insertions, 10 deletions
diff --git a/session.go b/session.go
index 08c6724..75404b3 100644
--- a/session.go
+++ b/session.go
@@ -49,8 +49,8 @@ type Session struct {
pings chan struct{}
timer *time.Timer
- locker sync.Mutex
- imapConn *imapclient.Client // protected by locker, can be nil
+ imapLocker sync.Mutex
+ imapConn *imapclient.Client // protected by locker, can be nil
}
func (s *Session) ping() {
@@ -65,8 +65,8 @@ func (s *Session) Username() string {
// DoIMAP executes an IMAP operation on this session. The IMAP client can only
// be used from inside f.
func (s *Session) DoIMAP(f func(*imapclient.Client) error) error {
- s.locker.Lock()
- defer s.locker.Unlock()
+ s.imapLocker.Lock()
+ defer s.imapLocker.Unlock()
if s.imapConn == nil {
var err error
@@ -214,17 +214,17 @@ func (sm *SessionManager) Put(username, password string) (*Session, error) {
alive := true
for alive {
var loggedOut <-chan struct{}
- s.locker.Lock()
+ s.imapLocker.Lock()
if s.imapConn != nil {
loggedOut = s.imapConn.LoggedOut()
}
- s.locker.Unlock()
+ s.imapLocker.Unlock()
select {
case <-loggedOut:
- s.locker.Lock()
+ s.imapLocker.Lock()
s.imapConn = nil
- s.locker.Unlock()
+ s.imapLocker.Unlock()
case <-s.pings:
if !timer.Stop() {
<-timer.C
@@ -239,11 +239,11 @@ func (sm *SessionManager) Put(username, password string) (*Session, error) {
timer.Stop()
- s.locker.Lock()
+ s.imapLocker.Lock()
if s.imapConn != nil {
s.imapConn.Logout()
}
- s.locker.Unlock()
+ s.imapLocker.Unlock()
sm.locker.Lock()
delete(sm.sessions, token)