Added lock for quorum registration 17/43417/3
authorKiran Kamineni <kiran.k.kamineni@intel.com>
Tue, 17 Apr 2018 18:49:21 +0000 (11:49 -0700)
committerKiran Kamineni <kiran.k.kamineni@intel.com>
Wed, 18 Apr 2018 21:15:48 +0000 (14:15 -0700)
Added lock for quorum registration
Removed debug statement

Issue-ID: AAF-92
Change-Id: Ib2de5ae7ed31b93b6853c78a70305a401ba3c014
Signed-off-by: Kiran Kamineni <kiran.k.kamineni@intel.com>
sms-service/src/quorumclient/quorumclient.go
sms-service/src/sms/backend/vault.go
sms-service/src/sms/handler/handler.go

index 7244720..05fc967 100644 (file)
@@ -25,6 +25,7 @@ import (
        "log"
        "net/http"
        "os"
+       "path/filepath"
        smsauth "sms/auth"
        smslogger "sms/log"
        "strings"
@@ -63,10 +64,11 @@ func loadPGPKeys(prKeyPath string, pbKeyPath string) (string, string, error) {
 //calls necessary initialization endpoints on the
 //SMS webservice
 func main() {
-       idFilePath := "auth/myid"
-       pbKeyPath := "auth/pbkey"
-       prKeyPath := "auth/prkey"
-       shardPath := "auth/shard"
+       podName := os.Getenv("HOSTNAME")
+       idFilePath := filepath.Join("auth", podName, "id")
+       pbKeyPath := filepath.Join("auth", podName, "pbkey")
+       prKeyPath := filepath.Join("auth", podName, "prkey")
+       shardPath := filepath.Join("auth", podName, "shard")
 
        smslogger.Init("")
        smslogger.WriteInfo("Starting Log for Quorum Client")
index 3360197..147d934 100644 (file)
@@ -95,6 +95,10 @@ func (v *Vault) GetStatus() (bool, error) {
 // RegisterQuorum registers the PGP public key for a quorum client
 // We will return a shard to the client that is registering
 func (v *Vault) RegisterQuorum(pgpkey string) (string, error) {
+
+       v.Lock()
+       defer v.Unlock()
+
        if v.shards == nil {
                smslogger.WriteError("Invalid operation")
                return "", errors.New("Invalid operation")
index 0568671..dbf3f93 100644 (file)
@@ -231,8 +231,6 @@ func (h handler) registerHandler(w http.ResponseWriter, r *http.Request) {
                QuorumID string `json:"quorumid"`
        }
 
-       smslogger.WriteInfo("Entering registerHandler")
-
        var inp registerStruct
        decoder := json.NewDecoder(r.Body)
        decoder.DisallowUnknownFields()