Browse code

Add an initial smaller sleep time before net dialing plugin socket.

Signed-off-by: Anusha Ragunathan <anusha.ragunathan@docker.com>

Anusha Ragunathan authored on 2017/04/07 03:16:35
Showing 1 changed files
... ...
@@ -88,9 +88,18 @@ func (pm *Manager) pluginPostStart(p *v2.Plugin, c *controller) error {
88 88
 
89 89
 	p.SetPClient(client)
90 90
 
91
+	// Initial sleep before net Dial to allow plugin to listen on socket.
92
+	time.Sleep(500 * time.Millisecond)
91 93
 	maxRetries := 3
92 94
 	var retries int
93 95
 	for {
96
+		// net dial into the unix socket to see if someone's listening.
97
+		conn, err := net.Dial("unix", sockAddr)
98
+		if err == nil {
99
+			conn.Close()
100
+			break
101
+		}
102
+
94 103
 		time.Sleep(3 * time.Second)
95 104
 		retries++
96 105
 
... ...
@@ -103,12 +112,6 @@ func (pm *Manager) pluginPostStart(p *v2.Plugin, c *controller) error {
103 103
 			return err
104 104
 		}
105 105
 
106
-		// net dial into the unix socket to see if someone's listening.
107
-		conn, err := net.Dial("unix", sockAddr)
108
-		if err == nil {
109
-			conn.Close()
110
-			break
111
-		}
112 106
 	}
113 107
 	pm.config.Store.SetState(p, true)
114 108
 	pm.config.Store.CallHandler(p)