aboutsummaryrefslogtreecommitdiffstats
path: root/lib/xdsserver/webserver.go
diff options
context:
space:
mode:
Diffstat (limited to 'lib/xdsserver/webserver.go')
-rw-r--r--lib/xdsserver/webserver.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/xdsserver/webserver.go b/lib/xdsserver/webserver.go
index 24456b9..a50b41e 100644
--- a/lib/xdsserver/webserver.go
+++ b/lib/xdsserver/webserver.go
@@ -84,6 +84,7 @@ func (s *WebServer) Serve() error {
s.router.Use(gin.Recovery())
s.router.Use(s.middlewareXDSDetails())
s.router.Use(s.middlewareCORS())
+ s.router.Use(s.lockRequest())
// Create REST API
s.api = NewAPIV1(s.Context)
@@ -172,6 +173,16 @@ func (s *WebServer) middlewareCORS() gin.HandlerFunc {
}
}
+//lockRequest handles to increment/decrement xds package update
+//to avoid updating xds-server when request is done
+func (s *WebServer) lockRequest() gin.HandlerFunc {
+ return func(c *gin.Context) {
+ LockXdsUpdateCounter(s.Context, true)
+ c.Next()
+ LockXdsUpdateCounter(s.Context, false)
+ }
+}
+
// socketHandler is the handler for the "main" websocket connection
func (s *WebServer) socketHandler(c *gin.Context) {