fork of https://github.com/sourcegraph/zoekt
0

Configure Feed

Select the types of activity you want to include in your feed.

Swap out all usages of the `syscall` package (#513)

with the `golang.org/x/sys/unix` package.

`syscall` has been frozen since Go 1.3 and deprecated
(https://go.dev/doc/go1.4#major_library_changes).

Using the `golang.org/x/sys/unix` package will bring in bug fixes
and enhancements since `syscall` was frozen in 1.3,
and will pave the way for multi-platform builds
(which will affect only the single-program local install, most likely).

author
Peter Guy
committer
GitHub
date (Jan 13, 2023, 8:21 PM +0200) commit a303c6c5 parent e0cf62d2
+29 -23
+4 -3
build/builder_unix.go
··· 19 19 20 20 import ( 21 21 "os" 22 - "syscall" 22 + 23 + "golang.org/x/sys/unix" 23 24 ) 24 25 25 26 func init() { 26 - umask = os.FileMode(syscall.Umask(0)) 27 - syscall.Umask(int(umask)) 27 + umask = os.FileMode(unix.Umask(0)) 28 + unix.Umask(int(umask)) 28 29 }
+6 -5
cmd/zoekt-sourcegraph-indexserver/main.go
··· 27 27 "strconv" 28 28 "strings" 29 29 "sync" 30 - "syscall" 31 30 "text/tabwriter" 32 31 "time" 32 + 33 + "golang.org/x/sys/unix" 33 34 34 35 "github.com/keegancsmith/tmpfriend" 35 36 "github.com/peterbourgon/ff/v3/ffcli" ··· 247 248 } else { 248 249 // Send quit (C-\) first so we get a stack dump. 249 250 log.Printf("no output for %s, quitting %s", noOutputTimeout, cmd.Args) 250 - if err := cmd.Process.Signal(syscall.SIGQUIT); err != nil { 251 + if err := cmd.Process.Signal(unix.SIGQUIT); err != nil { 251 252 log.Println("quit failed:", err) 252 253 } 253 254 ··· 312 313 // testing we also listen for SIGUSR1 to trigger updates. 313 314 // 314 315 // "pkill -SIGUSR1 zoekt-sourcegra" 315 - for range jitterTicker(s.Interval, syscall.SIGUSR1) { 316 + for range jitterTicker(s.Interval, unix.SIGUSR1) { 316 317 if b, err := os.ReadFile(filepath.Join(s.IndexDir, pauseFileName)); err == nil { 317 318 log.Printf("indexserver manually paused via PAUSE file: %s", string(bytes.TrimSpace(b))) 318 319 continue ··· 359 360 }() 360 361 361 362 go func() { 362 - for range jitterTicker(s.VacuumInterval, syscall.SIGUSR1) { 363 + for range jitterTicker(s.VacuumInterval, unix.SIGUSR1) { 363 364 if s.shardMerging { 364 365 s.vacuum() 365 366 } ··· 367 368 }() 368 369 369 370 go func() { 370 - for range jitterTicker(s.MergeInterval, syscall.SIGUSR1) { 371 + for range jitterTicker(s.MergeInterval, unix.SIGUSR1) { 371 372 if s.shardMerging { 372 373 s.doMerge() 373 374 }
+4 -3
cmd/zoekt-sourcegraph-indexserver/meta.go
··· 5 5 "fmt" 6 6 "os" 7 7 "path/filepath" 8 - "syscall" 8 + 9 + "golang.org/x/sys/unix" 9 10 10 11 "github.com/sourcegraph/zoekt" 11 12 "github.com/sourcegraph/zoekt/build" ··· 113 114 var umask os.FileMode 114 115 115 116 func init() { 116 - umask = os.FileMode(syscall.Umask(0)) 117 - syscall.Umask(int(umask)) 117 + umask = os.FileMode(unix.Umask(0)) 118 + unix.Umask(int(umask)) 118 119 }
+7 -6
cmd/zoekt-webserver/main.go
··· 36 36 "runtime" 37 37 "strconv" 38 38 "strings" 39 - "syscall" 40 39 "time" 40 + 41 + "golang.org/x/sys/unix" 41 42 42 43 "github.com/sourcegraph/mountinfo" 43 44 ··· 337 338 func shutdownSignalChan(maxReads int) <-chan os.Signal { 338 339 c := make(chan os.Signal, maxReads) 339 340 signal.Notify(c, os.Interrupt) // terminal C-c and goreman 340 - signal.Notify(c, syscall.SIGTERM) // Kubernetes 341 + signal.Notify(c, unix.SIGTERM) // Kubernetes 341 342 return c 342 343 } 343 344 ··· 442 443 Help: "Amount of free space disk space.", 443 444 ConstLabels: prometheus.Labels{"path": path}, 444 445 }, func() float64 { 445 - var stat syscall.Statfs_t 446 - _ = syscall.Statfs(path, &stat) 446 + var stat unix.Statfs_t 447 + _ = unix.Statfs(path, &stat) 447 448 return float64(stat.Bavail * uint64(stat.Bsize)) 448 449 })) 449 450 ··· 452 453 Help: "Amount of total disk space.", 453 454 ConstLabels: prometheus.Labels{"path": path}, 454 455 }, func() float64 { 455 - var stat syscall.Statfs_t 456 - _ = syscall.Statfs(path, &stat) 456 + var stat unix.Statfs_t 457 + _ = unix.Statfs(path, &stat) 457 458 return float64(stat.Blocks * uint64(stat.Bsize)) 458 459 })) 459 460 }
+4 -3
indexfile_unix.go
··· 20 20 "fmt" 21 21 "log" 22 22 "os" 23 - "syscall" 23 + 24 + "golang.org/x/sys/unix" 24 25 ) 25 26 26 27 type mmapedIndexFile struct { ··· 45 46 } 46 47 47 48 func (f *mmapedIndexFile) Close() { 48 - if err := syscall.Munmap(f.data); err != nil { 49 + if err := unix.Munmap(f.data); err != nil { 49 50 log.Printf("WARN failed to Munmap %s: %v", f.name, err) 50 51 } 51 52 } ··· 70 71 } 71 72 72 73 rounded := (r.size + 4095) &^ 4095 73 - r.data, err = syscall.Mmap(int(f.Fd()), 0, int(rounded), syscall.PROT_READ, syscall.MAP_SHARED) 74 + r.data, err = unix.Mmap(int(f.Fd()), 0, int(rounded), unix.PROT_READ, unix.MAP_SHARED) 74 75 if err != nil { 75 76 return nil, err 76 77 }
+4 -3
tombstones.go
··· 6 6 "os" 7 7 "path/filepath" 8 8 "strconv" 9 - "syscall" 9 + 10 + "golang.org/x/sys/unix" 10 11 ) 11 12 12 13 // ShardMergingEnabled returns true if SRC_ENABLE_SHARD_MERGING is set to true. ··· 104 105 var umask os.FileMode 105 106 106 107 func init() { 107 - umask = os.FileMode(syscall.Umask(0)) 108 - syscall.Umask(int(umask)) 108 + umask = os.FileMode(unix.Umask(0)) 109 + unix.Umask(int(umask)) 109 110 }