Skip to content

Commit

Permalink
proxy: unregisterVM free token
Browse files Browse the repository at this point in the history
When unregisterVM is called we want to free all the tokens we register
previously, all the tokens should not be valid anymore.

Fixes: clearcontainers#66

Signed-off-by: Jose Carlos Venegas Munoz <jose.carlos.venegas.munoz@intel.com>
  • Loading branch information
jcvenegas committed Aug 21, 2017
1 parent b9c1f2d commit f661105
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,11 @@ func unregisterVM(data []byte, userData interface{}, response *handlerResponse)
delete(proxy.vms, vm.containerID)
proxy.Unlock()

if err := vm.freeSessions(); err != nil {
response.SetErrorf("Failed to free Sessions: %s", err)
return
}

client.vm = nil
}

Expand Down
11 changes: 11 additions & 0 deletions vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,17 @@ func (vm *vm) AllocateSession() (*ioSession, error) {
return session, nil
}

func (vm *vm) freeSessions() error {
vm.Lock()
defer vm.Unlock()
for t := range vm.tokenToSession {
if err := vm.freeTokenUnlocked(t); err != nil {
return fmt.Errorf("Failed to free session with token %s", t)
}
}
return nil
}

// AssociateShim associates a shim given by the triplet (token, clientID,
// clientConn) to a vm (POD). After associating the shim, a hyper command can
// be issued to start the process inside the VM and data can flow between shim
Expand Down

0 comments on commit f661105

Please sign in to comment.