Handle all operations except mounting without forking a child
This saves 170ms for each start (why do we take 170ms to start up?) and cuts down test time by 2 seconds.
This commit is contained in:
parent
bb116282b7
commit
6f764b3867
1
TODO.md
1
TODO.md
@ -3,3 +3,4 @@
|
|||||||
* add test case
|
* add test case
|
||||||
* Add "--pwfile" parameter that reads the password from a file
|
* Add "--pwfile" parameter that reads the password from a file
|
||||||
* Use that for additional test cases
|
* Use that for additional test cases
|
||||||
|
* Find out why "./gocryptfs -version" takes 170ms.
|
||||||
|
9
main.go
9
main.go
@ -155,13 +155,10 @@ func main() {
|
|||||||
"Setting this to a lower value speeds up mounting but makes the password susceptible to brute-force attacks")
|
"Setting this to a lower value speeds up mounting but makes the password susceptible to brute-force attacks")
|
||||||
flagSet.Parse(os.Args[1:])
|
flagSet.Parse(os.Args[1:])
|
||||||
|
|
||||||
// By default, let the child handle everything.
|
// Fork a child into the background if "-f" is not set and we are mounting a filesystem
|
||||||
// The parent *could* handle operations that do not require backgrounding by
|
if !args.foreground && flagSet.NArg() == 2 {
|
||||||
// itself, but that would make the code paths more complicated.
|
|
||||||
if !args.foreground {
|
|
||||||
forkChild() // does not return
|
forkChild() // does not return
|
||||||
}
|
}
|
||||||
// Getting here means we *are* the child
|
|
||||||
// "-v"
|
// "-v"
|
||||||
if args.version {
|
if args.version {
|
||||||
printVersion()
|
printVersion()
|
||||||
@ -231,7 +228,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
// Mount
|
// Mount
|
||||||
// Check mountpoint
|
// Check mountpoint
|
||||||
if flagSet.NArg() < 2 {
|
if flagSet.NArg() != 2 {
|
||||||
usageText()
|
usageText()
|
||||||
os.Exit(ERREXIT_USAGE)
|
os.Exit(ERREXIT_USAGE)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user