auth-rpc: Reset token on disconnect (#2542)

master
Krishnan Parthasarathi 8 years ago committed by Harshavardhana
parent 7922a54c9a
commit c8dfc4cda4
  1. 10
      cmd/auth-rpc-client.go

@ -17,6 +17,7 @@
package cmd
import (
"net/rpc"
"time"
"github.com/minio/dsync"
@ -62,7 +63,7 @@ func (authClient *AuthRPCClient) Login() (string, time.Time, error) {
// Call - If rpc connection isn't established yet since previous disconnect,
// connection is established, a jwt authenticated login is performed and then
// the call is performed.
func (authClient *AuthRPCClient) Call(serviceMethod string, args dsync.TokenSetter, reply interface{}) (err error) {
func (authClient *AuthRPCClient) Call(serviceMethod string, args dsync.TokenSetter, reply interface{}) error {
if authClient.token == "" {
token, tstamp, err := authClient.Login()
if err != nil {
@ -75,5 +76,10 @@ func (authClient *AuthRPCClient) Call(serviceMethod string, args dsync.TokenSett
args.SetToken(token)
args.SetTimestamp(tstamp)
}
return authClient.rpc.Call(serviceMethod, args, reply)
err := authClient.rpc.Call(serviceMethod, args, reply)
// Reset token on disconnect to mark for re-login on subsequent reconnect.
if err != nil && err == rpc.ErrShutdown {
authClient.token = ""
}
return err
}

Loading…
Cancel
Save