|
@@ -49,20 +49,18 @@ func newSystem(id string) *System {
|
|
return &System{
|
|
return &System{
|
|
id: id,
|
|
id: id,
|
|
logctx: logrus.Fields{
|
|
logctx: logrus.Fields{
|
|
- logfields.HCSOperation: "",
|
|
|
|
- logfields.ContainerID: id,
|
|
|
|
|
|
+ logfields.ContainerID: id,
|
|
},
|
|
},
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
func (computeSystem *System) logOperationBegin(operation string) {
|
|
func (computeSystem *System) logOperationBegin(operation string) {
|
|
- computeSystem.logctx[logfields.HCSOperation] = operation
|
|
|
|
logOperationBegin(
|
|
logOperationBegin(
|
|
computeSystem.logctx,
|
|
computeSystem.logctx,
|
|
- "hcsshim::ComputeSystem - Begin Operation")
|
|
|
|
|
|
+ operation+" - Begin Operation")
|
|
}
|
|
}
|
|
|
|
|
|
-func (computeSystem *System) logOperationEnd(err error) {
|
|
|
|
|
|
+func (computeSystem *System) logOperationEnd(operation string, err error) {
|
|
var result string
|
|
var result string
|
|
if err == nil {
|
|
if err == nil {
|
|
result = "Success"
|
|
result = "Success"
|
|
@@ -72,9 +70,8 @@ func (computeSystem *System) logOperationEnd(err error) {
|
|
|
|
|
|
logOperationEnd(
|
|
logOperationEnd(
|
|
computeSystem.logctx,
|
|
computeSystem.logctx,
|
|
- "hcsshim::ComputeSystem - End Operation - "+result,
|
|
|
|
|
|
+ operation+" - End Operation - "+result,
|
|
err)
|
|
err)
|
|
- computeSystem.logctx[logfields.HCSOperation] = ""
|
|
|
|
}
|
|
}
|
|
|
|
|
|
// CreateComputeSystem creates a new compute system with the given configuration but does not start it.
|
|
// CreateComputeSystem creates a new compute system with the given configuration but does not start it.
|
|
@@ -83,7 +80,7 @@ func CreateComputeSystem(id string, hcsDocumentInterface interface{}) (_ *System
|
|
|
|
|
|
computeSystem := newSystem(id)
|
|
computeSystem := newSystem(id)
|
|
computeSystem.logOperationBegin(operation)
|
|
computeSystem.logOperationBegin(operation)
|
|
- defer computeSystem.logOperationEnd(err)
|
|
|
|
|
|
+ defer func() { computeSystem.logOperationEnd(operation, err) }()
|
|
|
|
|
|
hcsDocumentB, err := json.Marshal(hcsDocumentInterface)
|
|
hcsDocumentB, err := json.Marshal(hcsDocumentInterface)
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -97,13 +94,13 @@ func CreateComputeSystem(id string, hcsDocumentInterface interface{}) (_ *System
|
|
Debug("HCS ComputeSystem Document")
|
|
Debug("HCS ComputeSystem Document")
|
|
|
|
|
|
var (
|
|
var (
|
|
- resultp *uint16
|
|
|
|
- identity syscall.Handle
|
|
|
|
|
|
+ resultp *uint16
|
|
|
|
+ identity syscall.Handle
|
|
|
|
+ createError error
|
|
)
|
|
)
|
|
- completed := false
|
|
|
|
- go syscallWatcher(computeSystem.logctx, &completed)
|
|
|
|
- createError := hcsCreateComputeSystem(id, hcsDocument, identity, &computeSystem.handle, &resultp)
|
|
|
|
- completed = true
|
|
|
|
|
|
+ syscallWatcher(computeSystem.logctx, func() {
|
|
|
|
+ createError = hcsCreateComputeSystem(id, hcsDocument, identity, &computeSystem.handle, &resultp)
|
|
|
|
+ })
|
|
|
|
|
|
if createError == nil || IsPending(createError) {
|
|
if createError == nil || IsPending(createError) {
|
|
if err = computeSystem.registerCallback(); err != nil {
|
|
if err = computeSystem.registerCallback(); err != nil {
|
|
@@ -133,7 +130,13 @@ func OpenComputeSystem(id string) (_ *System, err error) {
|
|
|
|
|
|
computeSystem := newSystem(id)
|
|
computeSystem := newSystem(id)
|
|
computeSystem.logOperationBegin(operation)
|
|
computeSystem.logOperationBegin(operation)
|
|
- defer computeSystem.logOperationEnd(err)
|
|
|
|
|
|
+ defer func() {
|
|
|
|
+ if IsNotExist(err) {
|
|
|
|
+ computeSystem.logOperationEnd(operation, nil)
|
|
|
|
+ } else {
|
|
|
|
+ computeSystem.logOperationEnd(operation, err)
|
|
|
|
+ }
|
|
|
|
+ }()
|
|
|
|
|
|
var (
|
|
var (
|
|
handle hcsSystem
|
|
handle hcsSystem
|
|
@@ -157,12 +160,10 @@ func OpenComputeSystem(id string) (_ *System, err error) {
|
|
// GetComputeSystems gets a list of the compute systems on the system that match the query
|
|
// GetComputeSystems gets a list of the compute systems on the system that match the query
|
|
func GetComputeSystems(q schema1.ComputeSystemQuery) (_ []schema1.ContainerProperties, err error) {
|
|
func GetComputeSystems(q schema1.ComputeSystemQuery) (_ []schema1.ContainerProperties, err error) {
|
|
operation := "hcsshim::GetComputeSystems"
|
|
operation := "hcsshim::GetComputeSystems"
|
|
- fields := logrus.Fields{
|
|
|
|
- logfields.HCSOperation: operation,
|
|
|
|
- }
|
|
|
|
|
|
+ fields := logrus.Fields{}
|
|
logOperationBegin(
|
|
logOperationBegin(
|
|
fields,
|
|
fields,
|
|
- "hcsshim::ComputeSystem - Begin Operation")
|
|
|
|
|
|
+ operation+" - Begin Operation")
|
|
|
|
|
|
defer func() {
|
|
defer func() {
|
|
var result string
|
|
var result string
|
|
@@ -174,7 +175,7 @@ func GetComputeSystems(q schema1.ComputeSystemQuery) (_ []schema1.ContainerPrope
|
|
|
|
|
|
logOperationEnd(
|
|
logOperationEnd(
|
|
fields,
|
|
fields,
|
|
- "hcsshim::ComputeSystem - End Operation - "+result,
|
|
|
|
|
|
+ operation+" - End Operation - "+result,
|
|
err)
|
|
err)
|
|
}()
|
|
}()
|
|
|
|
|
|
@@ -193,10 +194,10 @@ func GetComputeSystems(q schema1.ComputeSystemQuery) (_ []schema1.ContainerPrope
|
|
resultp *uint16
|
|
resultp *uint16
|
|
computeSystemsp *uint16
|
|
computeSystemsp *uint16
|
|
)
|
|
)
|
|
- completed := false
|
|
|
|
- go syscallWatcher(fields, &completed)
|
|
|
|
- err = hcsEnumerateComputeSystems(query, &computeSystemsp, &resultp)
|
|
|
|
- completed = true
|
|
|
|
|
|
+
|
|
|
|
+ syscallWatcher(fields, func() {
|
|
|
|
+ err = hcsEnumerateComputeSystems(query, &computeSystemsp, &resultp)
|
|
|
|
+ })
|
|
events := processHcsResult(resultp)
|
|
events := processHcsResult(resultp)
|
|
if err != nil {
|
|
if err != nil {
|
|
return nil, &HcsError{Op: operation, Err: err, Events: events}
|
|
return nil, &HcsError{Op: operation, Err: err, Events: events}
|
|
@@ -221,7 +222,7 @@ func (computeSystem *System) Start() (err error) {
|
|
|
|
|
|
operation := "hcsshim::ComputeSystem::Start"
|
|
operation := "hcsshim::ComputeSystem::Start"
|
|
computeSystem.logOperationBegin(operation)
|
|
computeSystem.logOperationBegin(operation)
|
|
- defer computeSystem.logOperationEnd(err)
|
|
|
|
|
|
+ defer func() { computeSystem.logOperationEnd(operation, err) }()
|
|
|
|
|
|
if computeSystem.handle == 0 {
|
|
if computeSystem.handle == 0 {
|
|
return makeSystemError(computeSystem, "Start", "", ErrAlreadyClosed, nil)
|
|
return makeSystemError(computeSystem, "Start", "", ErrAlreadyClosed, nil)
|
|
@@ -254,10 +255,9 @@ func (computeSystem *System) Start() (err error) {
|
|
}
|
|
}
|
|
|
|
|
|
var resultp *uint16
|
|
var resultp *uint16
|
|
- completed := false
|
|
|
|
- go syscallWatcher(computeSystem.logctx, &completed)
|
|
|
|
- err = hcsStartComputeSystem(computeSystem.handle, "", &resultp)
|
|
|
|
- completed = true
|
|
|
|
|
|
+ syscallWatcher(computeSystem.logctx, func() {
|
|
|
|
+ err = hcsStartComputeSystem(computeSystem.handle, "", &resultp)
|
|
|
|
+ })
|
|
events, err := processAsyncHcsResult(err, resultp, computeSystem.callbackNumber, hcsNotificationSystemStartCompleted, &timeout.SystemStart)
|
|
events, err := processAsyncHcsResult(err, resultp, computeSystem.callbackNumber, hcsNotificationSystemStartCompleted, &timeout.SystemStart)
|
|
if err != nil {
|
|
if err != nil {
|
|
return makeSystemError(computeSystem, "Start", "", err, events)
|
|
return makeSystemError(computeSystem, "Start", "", err, events)
|
|
@@ -279,17 +279,22 @@ func (computeSystem *System) Shutdown() (err error) {
|
|
|
|
|
|
operation := "hcsshim::ComputeSystem::Shutdown"
|
|
operation := "hcsshim::ComputeSystem::Shutdown"
|
|
computeSystem.logOperationBegin(operation)
|
|
computeSystem.logOperationBegin(operation)
|
|
- defer computeSystem.logOperationEnd(err)
|
|
|
|
|
|
+ defer func() {
|
|
|
|
+ if IsAlreadyStopped(err) {
|
|
|
|
+ computeSystem.logOperationEnd(operation, nil)
|
|
|
|
+ } else {
|
|
|
|
+ computeSystem.logOperationEnd(operation, err)
|
|
|
|
+ }
|
|
|
|
+ }()
|
|
|
|
|
|
if computeSystem.handle == 0 {
|
|
if computeSystem.handle == 0 {
|
|
return makeSystemError(computeSystem, "Shutdown", "", ErrAlreadyClosed, nil)
|
|
return makeSystemError(computeSystem, "Shutdown", "", ErrAlreadyClosed, nil)
|
|
}
|
|
}
|
|
|
|
|
|
var resultp *uint16
|
|
var resultp *uint16
|
|
- completed := false
|
|
|
|
- go syscallWatcher(computeSystem.logctx, &completed)
|
|
|
|
- err = hcsShutdownComputeSystem(computeSystem.handle, "", &resultp)
|
|
|
|
- completed = true
|
|
|
|
|
|
+ syscallWatcher(computeSystem.logctx, func() {
|
|
|
|
+ err = hcsShutdownComputeSystem(computeSystem.handle, "", &resultp)
|
|
|
|
+ })
|
|
events := processHcsResult(resultp)
|
|
events := processHcsResult(resultp)
|
|
if err != nil {
|
|
if err != nil {
|
|
return makeSystemError(computeSystem, "Shutdown", "", err, events)
|
|
return makeSystemError(computeSystem, "Shutdown", "", err, events)
|
|
@@ -306,19 +311,24 @@ func (computeSystem *System) Terminate() (err error) {
|
|
|
|
|
|
operation := "hcsshim::ComputeSystem::Terminate"
|
|
operation := "hcsshim::ComputeSystem::Terminate"
|
|
computeSystem.logOperationBegin(operation)
|
|
computeSystem.logOperationBegin(operation)
|
|
- defer computeSystem.logOperationEnd(err)
|
|
|
|
|
|
+ defer func() {
|
|
|
|
+ if IsPending(err) {
|
|
|
|
+ computeSystem.logOperationEnd(operation, nil)
|
|
|
|
+ } else {
|
|
|
|
+ computeSystem.logOperationEnd(operation, err)
|
|
|
|
+ }
|
|
|
|
+ }()
|
|
|
|
|
|
if computeSystem.handle == 0 {
|
|
if computeSystem.handle == 0 {
|
|
return makeSystemError(computeSystem, "Terminate", "", ErrAlreadyClosed, nil)
|
|
return makeSystemError(computeSystem, "Terminate", "", ErrAlreadyClosed, nil)
|
|
}
|
|
}
|
|
|
|
|
|
var resultp *uint16
|
|
var resultp *uint16
|
|
- completed := false
|
|
|
|
- go syscallWatcher(computeSystem.logctx, &completed)
|
|
|
|
- err = hcsTerminateComputeSystem(computeSystem.handle, "", &resultp)
|
|
|
|
- completed = true
|
|
|
|
|
|
+ syscallWatcher(computeSystem.logctx, func() {
|
|
|
|
+ err = hcsTerminateComputeSystem(computeSystem.handle, "", &resultp)
|
|
|
|
+ })
|
|
events := processHcsResult(resultp)
|
|
events := processHcsResult(resultp)
|
|
- if err != nil {
|
|
|
|
|
|
+ if err != nil && err != ErrVmcomputeAlreadyStopped {
|
|
return makeSystemError(computeSystem, "Terminate", "", err, events)
|
|
return makeSystemError(computeSystem, "Terminate", "", err, events)
|
|
}
|
|
}
|
|
|
|
|
|
@@ -329,7 +339,7 @@ func (computeSystem *System) Terminate() (err error) {
|
|
func (computeSystem *System) Wait() (err error) {
|
|
func (computeSystem *System) Wait() (err error) {
|
|
operation := "hcsshim::ComputeSystem::Wait"
|
|
operation := "hcsshim::ComputeSystem::Wait"
|
|
computeSystem.logOperationBegin(operation)
|
|
computeSystem.logOperationBegin(operation)
|
|
- defer computeSystem.logOperationEnd(err)
|
|
|
|
|
|
+ defer func() { computeSystem.logOperationEnd(operation, err) }()
|
|
|
|
|
|
err = waitForNotification(computeSystem.callbackNumber, hcsNotificationSystemExited, nil)
|
|
err = waitForNotification(computeSystem.callbackNumber, hcsNotificationSystemExited, nil)
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -339,12 +349,27 @@ func (computeSystem *System) Wait() (err error) {
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// WaitExpectedError synchronously waits for the compute system to shutdown or
|
|
|
|
+// terminate, and ignores the passed error if it occurs.
|
|
|
|
+func (computeSystem *System) WaitExpectedError(expected error) (err error) {
|
|
|
|
+ operation := "hcsshim::ComputeSystem::WaitExpectedError"
|
|
|
|
+ computeSystem.logOperationBegin(operation)
|
|
|
|
+ defer func() { computeSystem.logOperationEnd(operation, err) }()
|
|
|
|
+
|
|
|
|
+ err = waitForNotification(computeSystem.callbackNumber, hcsNotificationSystemExited, nil)
|
|
|
|
+ if err != nil && getInnerError(err) != expected {
|
|
|
|
+ return makeSystemError(computeSystem, "WaitExpectedError", "", err, nil)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return nil
|
|
|
|
+}
|
|
|
|
+
|
|
// WaitTimeout synchronously waits for the compute system to terminate or the duration to elapse.
|
|
// WaitTimeout synchronously waits for the compute system to terminate or the duration to elapse.
|
|
// If the timeout expires, IsTimeout(err) == true
|
|
// If the timeout expires, IsTimeout(err) == true
|
|
func (computeSystem *System) WaitTimeout(timeout time.Duration) (err error) {
|
|
func (computeSystem *System) WaitTimeout(timeout time.Duration) (err error) {
|
|
operation := "hcsshim::ComputeSystem::WaitTimeout"
|
|
operation := "hcsshim::ComputeSystem::WaitTimeout"
|
|
computeSystem.logOperationBegin(operation)
|
|
computeSystem.logOperationBegin(operation)
|
|
- defer computeSystem.logOperationEnd(err)
|
|
|
|
|
|
+ defer func() { computeSystem.logOperationEnd(operation, err) }()
|
|
|
|
|
|
err = waitForNotification(computeSystem.callbackNumber, hcsNotificationSystemExited, &timeout)
|
|
err = waitForNotification(computeSystem.callbackNumber, hcsNotificationSystemExited, &timeout)
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -360,7 +385,7 @@ func (computeSystem *System) Properties(types ...schema1.PropertyType) (_ *schem
|
|
|
|
|
|
operation := "hcsshim::ComputeSystem::Properties"
|
|
operation := "hcsshim::ComputeSystem::Properties"
|
|
computeSystem.logOperationBegin(operation)
|
|
computeSystem.logOperationBegin(operation)
|
|
- defer computeSystem.logOperationEnd(err)
|
|
|
|
|
|
+ defer func() { computeSystem.logOperationEnd(operation, err) }()
|
|
|
|
|
|
queryj, err := json.Marshal(schema1.PropertyQuery{types})
|
|
queryj, err := json.Marshal(schema1.PropertyQuery{types})
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -372,10 +397,9 @@ func (computeSystem *System) Properties(types ...schema1.PropertyType) (_ *schem
|
|
Debug("HCS ComputeSystem Properties Query")
|
|
Debug("HCS ComputeSystem Properties Query")
|
|
|
|
|
|
var resultp, propertiesp *uint16
|
|
var resultp, propertiesp *uint16
|
|
- completed := false
|
|
|
|
- go syscallWatcher(computeSystem.logctx, &completed)
|
|
|
|
- err = hcsGetComputeSystemProperties(computeSystem.handle, string(queryj), &propertiesp, &resultp)
|
|
|
|
- completed = true
|
|
|
|
|
|
+ syscallWatcher(computeSystem.logctx, func() {
|
|
|
|
+ err = hcsGetComputeSystemProperties(computeSystem.handle, string(queryj), &propertiesp, &resultp)
|
|
|
|
+ })
|
|
events := processHcsResult(resultp)
|
|
events := processHcsResult(resultp)
|
|
if err != nil {
|
|
if err != nil {
|
|
return nil, makeSystemError(computeSystem, "Properties", "", err, events)
|
|
return nil, makeSystemError(computeSystem, "Properties", "", err, events)
|
|
@@ -400,17 +424,16 @@ func (computeSystem *System) Pause() (err error) {
|
|
|
|
|
|
operation := "hcsshim::ComputeSystem::Pause"
|
|
operation := "hcsshim::ComputeSystem::Pause"
|
|
computeSystem.logOperationBegin(operation)
|
|
computeSystem.logOperationBegin(operation)
|
|
- defer computeSystem.logOperationEnd(err)
|
|
|
|
|
|
+ defer func() { computeSystem.logOperationEnd(operation, err) }()
|
|
|
|
|
|
if computeSystem.handle == 0 {
|
|
if computeSystem.handle == 0 {
|
|
return makeSystemError(computeSystem, "Pause", "", ErrAlreadyClosed, nil)
|
|
return makeSystemError(computeSystem, "Pause", "", ErrAlreadyClosed, nil)
|
|
}
|
|
}
|
|
|
|
|
|
var resultp *uint16
|
|
var resultp *uint16
|
|
- completed := false
|
|
|
|
- go syscallWatcher(computeSystem.logctx, &completed)
|
|
|
|
- err = hcsPauseComputeSystem(computeSystem.handle, "", &resultp)
|
|
|
|
- completed = true
|
|
|
|
|
|
+ syscallWatcher(computeSystem.logctx, func() {
|
|
|
|
+ err = hcsPauseComputeSystem(computeSystem.handle, "", &resultp)
|
|
|
|
+ })
|
|
events, err := processAsyncHcsResult(err, resultp, computeSystem.callbackNumber, hcsNotificationSystemPauseCompleted, &timeout.SystemPause)
|
|
events, err := processAsyncHcsResult(err, resultp, computeSystem.callbackNumber, hcsNotificationSystemPauseCompleted, &timeout.SystemPause)
|
|
if err != nil {
|
|
if err != nil {
|
|
return makeSystemError(computeSystem, "Pause", "", err, events)
|
|
return makeSystemError(computeSystem, "Pause", "", err, events)
|
|
@@ -426,17 +449,16 @@ func (computeSystem *System) Resume() (err error) {
|
|
|
|
|
|
operation := "hcsshim::ComputeSystem::Resume"
|
|
operation := "hcsshim::ComputeSystem::Resume"
|
|
computeSystem.logOperationBegin(operation)
|
|
computeSystem.logOperationBegin(operation)
|
|
- defer computeSystem.logOperationEnd(err)
|
|
|
|
|
|
+ defer func() { computeSystem.logOperationEnd(operation, err) }()
|
|
|
|
|
|
if computeSystem.handle == 0 {
|
|
if computeSystem.handle == 0 {
|
|
return makeSystemError(computeSystem, "Resume", "", ErrAlreadyClosed, nil)
|
|
return makeSystemError(computeSystem, "Resume", "", ErrAlreadyClosed, nil)
|
|
}
|
|
}
|
|
|
|
|
|
var resultp *uint16
|
|
var resultp *uint16
|
|
- completed := false
|
|
|
|
- go syscallWatcher(computeSystem.logctx, &completed)
|
|
|
|
- err = hcsResumeComputeSystem(computeSystem.handle, "", &resultp)
|
|
|
|
- completed = true
|
|
|
|
|
|
+ syscallWatcher(computeSystem.logctx, func() {
|
|
|
|
+ err = hcsResumeComputeSystem(computeSystem.handle, "", &resultp)
|
|
|
|
+ })
|
|
events, err := processAsyncHcsResult(err, resultp, computeSystem.callbackNumber, hcsNotificationSystemResumeCompleted, &timeout.SystemResume)
|
|
events, err := processAsyncHcsResult(err, resultp, computeSystem.callbackNumber, hcsNotificationSystemResumeCompleted, &timeout.SystemResume)
|
|
if err != nil {
|
|
if err != nil {
|
|
return makeSystemError(computeSystem, "Resume", "", err, events)
|
|
return makeSystemError(computeSystem, "Resume", "", err, events)
|
|
@@ -452,7 +474,7 @@ func (computeSystem *System) CreateProcess(c interface{}) (_ *Process, err error
|
|
|
|
|
|
operation := "hcsshim::ComputeSystem::CreateProcess"
|
|
operation := "hcsshim::ComputeSystem::CreateProcess"
|
|
computeSystem.logOperationBegin(operation)
|
|
computeSystem.logOperationBegin(operation)
|
|
- defer computeSystem.logOperationEnd(err)
|
|
|
|
|
|
+ defer func() { computeSystem.logOperationEnd(operation, err) }()
|
|
|
|
|
|
var (
|
|
var (
|
|
processInfo hcsProcessInformation
|
|
processInfo hcsProcessInformation
|
|
@@ -475,10 +497,9 @@ func (computeSystem *System) CreateProcess(c interface{}) (_ *Process, err error
|
|
WithField(logfields.JSON, configuration).
|
|
WithField(logfields.JSON, configuration).
|
|
Debug("HCS ComputeSystem Process Document")
|
|
Debug("HCS ComputeSystem Process Document")
|
|
|
|
|
|
- completed := false
|
|
|
|
- go syscallWatcher(computeSystem.logctx, &completed)
|
|
|
|
- err = hcsCreateProcess(computeSystem.handle, configuration, &processInfo, &processHandle, &resultp)
|
|
|
|
- completed = true
|
|
|
|
|
|
+ syscallWatcher(computeSystem.logctx, func() {
|
|
|
|
+ err = hcsCreateProcess(computeSystem.handle, configuration, &processInfo, &processHandle, &resultp)
|
|
|
|
+ })
|
|
events := processHcsResult(resultp)
|
|
events := processHcsResult(resultp)
|
|
if err != nil {
|
|
if err != nil {
|
|
return nil, makeSystemError(computeSystem, "CreateProcess", configuration, err, events)
|
|
return nil, makeSystemError(computeSystem, "CreateProcess", configuration, err, events)
|
|
@@ -513,7 +534,7 @@ func (computeSystem *System) OpenProcess(pid int) (_ *Process, err error) {
|
|
|
|
|
|
operation := "hcsshim::ComputeSystem::OpenProcess"
|
|
operation := "hcsshim::ComputeSystem::OpenProcess"
|
|
computeSystem.logOperationBegin(operation)
|
|
computeSystem.logOperationBegin(operation)
|
|
- defer computeSystem.logOperationEnd(err)
|
|
|
|
|
|
+ defer func() { computeSystem.logOperationEnd(operation, err) }()
|
|
|
|
|
|
var (
|
|
var (
|
|
processHandle hcsProcess
|
|
processHandle hcsProcess
|
|
@@ -524,10 +545,9 @@ func (computeSystem *System) OpenProcess(pid int) (_ *Process, err error) {
|
|
return nil, makeSystemError(computeSystem, "OpenProcess", "", ErrAlreadyClosed, nil)
|
|
return nil, makeSystemError(computeSystem, "OpenProcess", "", ErrAlreadyClosed, nil)
|
|
}
|
|
}
|
|
|
|
|
|
- completed := false
|
|
|
|
- go syscallWatcher(computeSystem.logctx, &completed)
|
|
|
|
- err = hcsOpenProcess(computeSystem.handle, uint32(pid), &processHandle, &resultp)
|
|
|
|
- completed = true
|
|
|
|
|
|
+ syscallWatcher(computeSystem.logctx, func() {
|
|
|
|
+ err = hcsOpenProcess(computeSystem.handle, uint32(pid), &processHandle, &resultp)
|
|
|
|
+ })
|
|
events := processHcsResult(resultp)
|
|
events := processHcsResult(resultp)
|
|
if err != nil {
|
|
if err != nil {
|
|
return nil, makeSystemError(computeSystem, "OpenProcess", "", err, events)
|
|
return nil, makeSystemError(computeSystem, "OpenProcess", "", err, events)
|
|
@@ -548,7 +568,7 @@ func (computeSystem *System) Close() (err error) {
|
|
|
|
|
|
operation := "hcsshim::ComputeSystem::Close"
|
|
operation := "hcsshim::ComputeSystem::Close"
|
|
computeSystem.logOperationBegin(operation)
|
|
computeSystem.logOperationBegin(operation)
|
|
- defer computeSystem.logOperationEnd(err)
|
|
|
|
|
|
+ defer func() { computeSystem.logOperationEnd(operation, err) }()
|
|
|
|
|
|
// Don't double free this
|
|
// Don't double free this
|
|
if computeSystem.handle == 0 {
|
|
if computeSystem.handle == 0 {
|
|
@@ -559,10 +579,9 @@ func (computeSystem *System) Close() (err error) {
|
|
return makeSystemError(computeSystem, "Close", "", err, nil)
|
|
return makeSystemError(computeSystem, "Close", "", err, nil)
|
|
}
|
|
}
|
|
|
|
|
|
- completed := false
|
|
|
|
- go syscallWatcher(computeSystem.logctx, &completed)
|
|
|
|
- err = hcsCloseComputeSystem(computeSystem.handle)
|
|
|
|
- completed = true
|
|
|
|
|
|
+ syscallWatcher(computeSystem.logctx, func() {
|
|
|
|
+ err = hcsCloseComputeSystem(computeSystem.handle)
|
|
|
|
+ })
|
|
if err != nil {
|
|
if err != nil {
|
|
return makeSystemError(computeSystem, "Close", "", err, nil)
|
|
return makeSystemError(computeSystem, "Close", "", err, nil)
|
|
}
|
|
}
|
|
@@ -636,7 +655,7 @@ func (computeSystem *System) Modify(config interface{}) (err error) {
|
|
|
|
|
|
operation := "hcsshim::ComputeSystem::Modify"
|
|
operation := "hcsshim::ComputeSystem::Modify"
|
|
computeSystem.logOperationBegin(operation)
|
|
computeSystem.logOperationBegin(operation)
|
|
- defer computeSystem.logOperationEnd(err)
|
|
|
|
|
|
+ defer func() { computeSystem.logOperationEnd(operation, err) }()
|
|
|
|
|
|
if computeSystem.handle == 0 {
|
|
if computeSystem.handle == 0 {
|
|
return makeSystemError(computeSystem, "Modify", "", ErrAlreadyClosed, nil)
|
|
return makeSystemError(computeSystem, "Modify", "", ErrAlreadyClosed, nil)
|
|
@@ -654,10 +673,9 @@ func (computeSystem *System) Modify(config interface{}) (err error) {
|
|
Debug("HCS ComputeSystem Modify Document")
|
|
Debug("HCS ComputeSystem Modify Document")
|
|
|
|
|
|
var resultp *uint16
|
|
var resultp *uint16
|
|
- completed := false
|
|
|
|
- go syscallWatcher(computeSystem.logctx, &completed)
|
|
|
|
- err = hcsModifyComputeSystem(computeSystem.handle, requestString, &resultp)
|
|
|
|
- completed = true
|
|
|
|
|
|
+ syscallWatcher(computeSystem.logctx, func() {
|
|
|
|
+ err = hcsModifyComputeSystem(computeSystem.handle, requestString, &resultp)
|
|
|
|
+ })
|
|
events := processHcsResult(resultp)
|
|
events := processHcsResult(resultp)
|
|
if err != nil {
|
|
if err != nil {
|
|
return makeSystemError(computeSystem, "Modify", requestString, err, events)
|
|
return makeSystemError(computeSystem, "Modify", requestString, err, events)
|