Browse Source

vendor: Update github.com/zillode/notify (#4734)

Simon Frei 7 năm trước cách đây
mục cha
commit
c7cf361a96

+ 8 - 5
vendor/github.com/zillode/notify/watcher_fsevents_cgo.go

@@ -26,9 +26,9 @@ import "C"
 import (
 	"errors"
 	"os"
+	"runtime"
 	"sync"
 	"sync/atomic"
-	"time"
 	"unsafe"
 )
 
@@ -48,7 +48,7 @@ var wg sync.WaitGroup      // used to wait until the runloop starts
 // started and is ready via the wg. It also serves purpose of a dummy source,
 // thanks to it the runloop does not return as it also has at least one source
 // registered.
-var source = C.CFRunLoopSourceCreate(refZero, 0, &C.CFRunLoopSourceContext{
+var source = C.CFRunLoopSourceCreate(nil, 0, &C.CFRunLoopSourceContext{
 	perform: (C.CFRunLoopPerformCallBack)(C.gosource),
 })
 
@@ -63,6 +63,10 @@ var (
 func init() {
 	wg.Add(1)
 	go func() {
+		// There is exactly one run loop per thread. Lock this goroutine to its
+		// thread to ensure that it's not rescheduled on a different thread while
+		// setting up the run loop.
+		runtime.LockOSThread()
 		runloop = C.CFRunLoopGetCurrent()
 		C.CFRunLoopAddSource(runloop, source, C.kCFRunLoopDefaultMode)
 		C.CFRunLoopRun()
@@ -73,7 +77,6 @@ func init() {
 
 //export gosource
 func gosource(unsafe.Pointer) {
-	time.Sleep(time.Second)
 	wg.Done()
 }
 
@@ -159,8 +162,8 @@ func (s *stream) Start() error {
 		return nil
 	}
 	wg.Wait()
-	p := C.CFStringCreateWithCStringNoCopy(refZero, C.CString(s.path), C.kCFStringEncodingUTF8, refZero)
-	path := C.CFArrayCreate(refZero, (*unsafe.Pointer)(unsafe.Pointer(&p)), 1, nil)
+	p := C.CFStringCreateWithCStringNoCopy(nil, C.CString(s.path), C.kCFStringEncodingUTF8, nil)
+	path := C.CFArrayCreate(nil, (*unsafe.Pointer)(unsafe.Pointer(&p)), 1, nil)
 	ctx := C.FSEventStreamContext{}
 	ref := C.EventStreamCreate(&ctx, C.uintptr_t(s.info), path, C.FSEventStreamEventId(atomic.LoadUint64(&since)), latency, flags)
 	if ref == nilstream {

+ 0 - 9
vendor/github.com/zillode/notify/watcher_fsevents_go1.10.go

@@ -1,9 +0,0 @@
-// Copyright (c) 2017 The Notify Authors. All rights reserved.
-// Use of this source code is governed by the MIT license that can be
-// found in the LICENSE file.
-
-// +build darwin,!kqueue,go1.10
-
-package notify
-
-const refZero = 0

+ 0 - 14
vendor/github.com/zillode/notify/watcher_fsevents_go1.9.go

@@ -1,14 +0,0 @@
-// Copyright (c) 2017 The Notify Authors. All rights reserved.
-// Use of this source code is governed by the MIT license that can be
-// found in the LICENSE file.
-
-// +build darwin,!kqueue,cgo,!go1.10
-
-package notify
-
-/*
-#include <CoreServices/CoreServices.h>
-*/
-import "C"
-
-var refZero = (*C.struct___CFAllocator)(nil)

+ 1 - 1
vendor/manifest

@@ -544,7 +544,7 @@
 			"importpath": "github.com/zillode/notify",
 			"repository": "https://github.com/zillode/notify",
 			"vcs": "git",
-			"revision": "8fff849a2026ce7a59f67ed9747dd9c7adc8bd0b",
+			"revision": "a8abcfb1ce88ee8d79a300ed65d94b8fb616ddb3",
 			"branch": "master",
 			"notests": true
 		},