summaryrefslogtreecommitdiffstats
path: root/sms-service
diff options
context:
space:
mode:
authorKiran Kamineni <kiran.k.kamineni@intel.com>2018-04-17 11:49:21 -0700
committerKiran Kamineni <kiran.k.kamineni@intel.com>2018-04-18 14:15:48 -0700
commitd2fb77cf298e97eeb998bf1a5e00f06431afd3fc (patch)
tree03c6d8ec2738e03b422c6a0aa18ad8d345fa9943 /sms-service
parent18ba7e30db0d8c10fa661224dad3d65e6c46abea (diff)
Added lock for quorum registration
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>
Diffstat (limited to 'sms-service')
-rw-r--r--sms-service/src/quorumclient/quorumclient.go10
-rw-r--r--sms-service/src/sms/backend/vault.go4
-rw-r--r--sms-service/src/sms/handler/handler.go2
3 files changed, 10 insertions, 6 deletions
diff --git a/sms-service/src/quorumclient/quorumclient.go b/sms-service/src/quorumclient/quorumclient.go
index 7244720..05fc967 100644
--- a/sms-service/src/quorumclient/quorumclient.go
+++ b/sms-service/src/quorumclient/quorumclient.go
@@ -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")
diff --git a/sms-service/src/sms/backend/vault.go b/sms-service/src/sms/backend/vault.go
index 3360197..147d934 100644
--- a/sms-service/src/sms/backend/vault.go
+++ b/sms-service/src/sms/backend/vault.go
@@ -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")
diff --git a/sms-service/src/sms/handler/handler.go b/sms-service/src/sms/handler/handler.go
index 0568671..dbf3f93 100644
--- a/sms-service/src/sms/handler/handler.go
+++ b/sms-service/src/sms/handler/handler.go
@@ -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()