浏览代码

windows/svc: align ctlHandler parameters

ctlHandler is passed to RegisterServiceCtrlHandlerEx as a callback
function. But all ctlHandler parameters have to be uintptr aligned
regardless of their type.

Adjust ctlHandler parameters, so they are aligned accordingly.

Also uncomment part of TestExample that verifies passing of
ChangeRequest.Context.

Fixes golang/go#25660

Change-Id: Ie96fa5c78b911ad9df6775f5c49e7f6d56464f6b
Reviewed-on: https://go-review.googlesource.com/c/158698
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Alex Brainman 6 年之前
父节点
当前提交
b6889370fb
共有 2 个文件被更改,包括 3 次插入4 次删除
  1. 2 2
      windows/svc/service.go
  2. 1 2
      windows/svc/svc_test.go

+ 2 - 2
windows/svc/service.go

@@ -315,8 +315,8 @@ func Run(name string, handler Handler) error {
 		return err
 	}
 
-	ctlHandler := func(ctl uint32, evtype uint32, evdata uintptr, context uintptr) uintptr {
-		e := ctlEvent{cmd: Cmd(ctl), eventType: evtype, eventData: evdata, context: context}
+	ctlHandler := func(ctl, evtype, evdata, context uintptr) uintptr {
+		e := ctlEvent{cmd: Cmd(ctl), eventType: uint32(evtype), eventData: evdata, context: context}
 		// We assume that this callback function is running on
 		// the same thread as Run. Nowhere in MS documentation
 		// I could find statement to guarantee that. So putting

+ 1 - 2
windows/svc/svc_test.go

@@ -127,8 +127,7 @@ func TestExample(t *testing.T) {
 	}
 	want := strings.Join(append([]string{name}, args...), "-")
 	// Test context passing (see servicemain in sys_386.s and sys_amd64.s).
-	// TODO(brainman): Uncomment next line once issue #25660 is fixed.
-	//want += "-123456"
+	want += "-123456"
 	if !strings.Contains(string(out), want) {
 		t.Errorf("%q string does not contain %q", string(out), want)
 	}