File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -127,19 +127,20 @@ func (mgr *NetworkManager) addNetConfig() {
127127
128128// allocNetConfig allocates a new network config from the pool to a function instance identified by funcID
129129func (mgr * NetworkManager ) allocNetConfig (funcID string ) * NetworkConfig {
130- // Add netconfig to pool to keep pool to configured size
131- go mgr .addNetConfig ()
132-
133130 logger := log .WithFields (log.Fields {"funcID" : funcID })
134131 logger .Debug ("Allocating a new network config from network pool to function instance" )
135132
136- // Pop a network config from the pool and allocate it to the function instance
137133 mgr .poolCond .L .Lock ()
134+ // Add netconfig to pool to keep pool to configured size
135+ if len (mgr .networkPool ) <= mgr .poolSize {
136+ go mgr .addNetConfig ()
137+ }
138138 for len (mgr .networkPool ) == 0 {
139139 // Wait until a new network config has been created
140140 mgr .poolCond .Wait ()
141141 }
142142
143+ // Pop a network config from the pool and allocate it to the function instance
143144 config := mgr .networkPool [len (mgr .networkPool )- 1 ]
144145 mgr .networkPool = mgr .networkPool [:len (mgr .networkPool )- 1 ]
145146 mgr .poolCond .L .Unlock ()
You can’t perform that action at this time.
0 commit comments