Files
clio/tools/requests_gun/requests_gun.go
Sergey Kuznetsov d11e7bc60e fix: Data race in new webserver (#1926)
There was a data race inside `CoroutineGroup` because internal timer was
used from multiple threads in the methods `asyncWait()` and
`onCoroutineComplete()`. Changing `registerForeign()` to spawn to the
same `yield_context` fixes the problem because now the timer is accessed
only from the same coroutine which has an internal strand.

During debugging I also added websocket support for `request_gun` tool.
2025-02-27 15:08:46 +00:00

37 lines
718 B
Go

package main
import (
"fmt"
"os"
"requests_gun/internal/ammo_provider"
"requests_gun/internal/parse_args"
"requests_gun/internal/trigger"
)
func main() {
args, err := parse_args.Parse()
if err != nil {
fmt.Fprintln(os.Stderr, "Error: ", err)
parse_args.PrintUsage()
os.Exit(1)
}
if args.Help {
parse_args.PrintUsage()
os.Exit(0)
}
fmt.Print("Loading ammo... ")
f, err := os.Open(args.Ammo)
if err != nil {
fmt.Println("Error opening file '", args.Ammo, "': ", err)
os.Exit(1)
}
ammoProvider := ammo_provider.New(f)
f.Close()
fmt.Println("Done")
fmt.Println("Firing requests...")
trigger.Fire(ammoProvider, args)
}