Skip to content

Commit

Permalink
log: rename to logPanicAndExit to HandlePanic
Browse files Browse the repository at this point in the history
According to the linter
```
func name will be used as log.LogPanicAndExit by other packages, and that stutters; consider calling this PanicAndExit

```

Contributes scionproto#3592
  • Loading branch information
karampok committed Jan 30, 2020
1 parent 299a765 commit 633b61b
Show file tree
Hide file tree
Showing 69 changed files with 121 additions and 121 deletions.
2 changes: 1 addition & 1 deletion go/acceptance/sig_ping_acceptance/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func realMain() int {
fmt.Fprintf(os.Stderr, "Failed to init: %s\n", err)
return 1
}
defer log.LogPanicAndExit()
defer log.HandlePanic()
defer log.Flush()
if !*integration.Docker {
log.Crit(fmt.Sprintf("Can only run %s test with docker!", name))
Expand Down
4 changes: 2 additions & 2 deletions go/beacon_srv/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func realMain() int {
}
defer log.Flush()
defer env.LogAppStopped(common.BS, cfg.General.ID)
defer log.LogPanicAndExit()
defer log.HandlePanic()
if err := setup(); err != nil {
log.Crit("Setup failed", "err", err)
return 1
Expand Down Expand Up @@ -208,7 +208,7 @@ func realMain() int {
cfg.Metrics.StartPrometheus()

go func() {
defer log.LogPanicAndExit()
defer log.HandlePanic()
msgr.ListenAndServe()
}()
dispatcherService := reliable.NewDispatcher("")
Expand Down
2 changes: 1 addition & 1 deletion go/border/braccept/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func realMain() int {
fmt.Fprintf(os.Stderr, "%s\n", err)
return 1
}
defer log.LogPanicAndExit()
defer log.HandlePanic()
if err := shared.Init(keysDirPath); err != nil {
log.Crit("Initialization failed", "err", err)
return 1
Expand Down
4 changes: 2 additions & 2 deletions go/border/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const (
)

func (r *Router) posixInput(s *rctx.Sock, stop, stopped chan struct{}) {
defer log.LogPanicAndExit()
defer log.HandlePanic()
defer close(stopped)
dst := s.Conn.LocalAddr()
log.Info("posixInput starting", "addr", dst)
Expand Down Expand Up @@ -193,7 +193,7 @@ func (r *Router) posixInputRead(msgs []ipv4.Message, metas []conn.ReadMeta,
}

func (r *Router) posixOutput(s *rctx.Sock, _, stopped chan struct{}) {
defer log.LogPanicAndExit()
defer log.HandlePanic()
defer close(stopped)
src := s.Conn.LocalAddr()
dst := s.Conn.RemoteAddr()
Expand Down
2 changes: 1 addition & 1 deletion go/border/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func realMain() int {
}
defer log.Flush()
defer env.LogAppStopped(common.BR, cfg.General.ID)
defer log.LogPanicAndExit()
defer log.HandlePanic()
http.HandleFunc("/config", configHandler)
http.HandleFunc("/info", env.InfoHandler)
http.HandleFunc("/topology", itopo.TopologyHandler)
Expand Down
4 changes: 2 additions & 2 deletions go/border/rctrl/ctrl.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ func Control(sRevInfoQ chan rpkt.RawSRevCallbackArgs, dispatcherReconnect bool)
fatal.Fatal(common.NewBasicError("Listening on address", err, "addr", ctrlAddr))
}
go func() {
defer log.LogPanicAndExit()
defer log.HandlePanic()
ifStateUpdate()
}()
go func() {
defer log.LogPanicAndExit()
defer log.HandlePanic()
revInfoFwd(sRevInfoQ)
}()
processCtrl()
Expand Down
4 changes: 2 additions & 2 deletions go/border/rctx/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ func (s *Sock) Start() {
}
if s.Reader != nil {
go func() {
defer log.LogPanicAndExit()
defer log.HandlePanic()
s.Reader(s, s.stop, s.readerStopped)
}()
}
if s.Writer != nil {
go func() {
defer log.LogPanicAndExit()
defer log.HandlePanic()
s.Writer(s, s.stop, s.writerStopped)
}()
}
Expand Down
6 changes: 3 additions & 3 deletions go/border/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ func NewRouter(id, confDir string) (*Router, error) {
// processing as well as various other router functions.
func (r *Router) Start() {
go func() {
defer log.LogPanicAndExit()
defer log.HandlePanic()
r.PacketError()
}()
go func() {
defer log.LogPanicAndExit()
defer log.HandlePanic()
rctrl.Control(r.sRevInfoQ, cfg.General.ReconnectToDispatcher)
}()
if err := r.startDiscovery(); err != nil {
Expand All @@ -92,7 +92,7 @@ func (r *Router) ReloadConfig() error {
}

func (r *Router) handleSock(s *rctx.Sock, stop, stopped chan struct{}) {
defer log.LogPanicAndExit()
defer log.HandlePanic()
defer close(stopped)
pkts := make(ringbuf.EntryList, processBufCnt)
dst := s.Conn.LocalAddr()
Expand Down
4 changes: 2 additions & 2 deletions go/cert_srv/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func realMain() int {
}
defer log.Flush()
defer env.LogAppStopped(common.CS, cfg.General.ID)
defer log.LogPanicAndExit()
defer log.HandlePanic()
if err := setup(); err != nil {
log.Crit("Setup failed", "err", err)
return 1
Expand Down Expand Up @@ -190,7 +190,7 @@ func realMain() int {

// Start the messenger.
go func() {
defer log.LogPanicAndExit()
defer log.HandlePanic()
msgr.ListenAndServe()
}()

Expand Down
4 changes: 2 additions & 2 deletions go/cs/beacon/beacondbsqlite/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func (e *executor) AllRevocations(ctx context.Context) (<-chan beacon.Revocation
}
res := make(chan beacon.RevocationOrErr)
go func() {
defer log.LogPanicAndExit()
defer log.HandlePanic()
defer close(res)
defer rows.Close()
for rows.Next() {
Expand Down Expand Up @@ -232,7 +232,7 @@ func (e *executor) CandidateBeacons(ctx context.Context, setSize int, usage beac
}
results := make(chan beacon.BeaconOrErr)
go func() {
defer log.LogPanicAndExit()
defer log.HandlePanic()
defer close(results)
for _, b := range beacons {
results <- beacon.BeaconOrErr{Beacon: b}
Expand Down
6 changes: 3 additions & 3 deletions go/cs/beacon/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (s *Store) getBeacons(ctx context.Context, policy *Policy) (<-chan BeaconOr
}
results := make(chan BeaconOrErr, min(maxResultChanSize, policy.BestSetSize))
go func() {
defer log.LogPanicAndExit()
defer log.HandlePanic()
defer close(results)
s.algo.SelectAndServe(beacons, results, policy.BestSetSize)
}()
Expand Down Expand Up @@ -181,13 +181,13 @@ func (s *CoreStore) getBeacons(ctx context.Context, policy *Policy) (<-chan Beac
}
wg.Add(1)
go func() {
defer log.LogPanicAndExit()
defer log.HandlePanic()
defer wg.Done()
s.algo.SelectAndServe(beacons, results, policy.BestSetSize)
}()
}
go func() {
defer log.LogPanicAndExit()
defer log.HandlePanic()
defer close(results)
wg.Wait()
if len(errs) > 0 {
Expand Down
4 changes: 2 additions & 2 deletions go/cs/beaconing/propagator.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ type beaconPropagator struct {
func (p *beaconPropagator) start(ctx context.Context, wg *sync.WaitGroup) {
wg.Add(1)
go func() {
defer log.LogPanicAndExit()
defer log.HandlePanic()
defer wg.Done()
if err := p.propagate(ctx); err != nil {
p.logger.Error("[beaconing.Propagator] Unable to propagate",
Expand Down Expand Up @@ -248,7 +248,7 @@ func (p *beaconPropagator) extendAndSend(ctx context.Context, bseg beacon.Beacon

p.wg.Add(1)
go func() {
defer log.LogPanicAndExit()
defer log.HandlePanic()
defer p.wg.Done()

labels := metrics.PropagatorLabels{
Expand Down
2 changes: 1 addition & 1 deletion go/cs/beaconing/registrar.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func (r *segmentRegistrar) setSegToRegister() error {
func (r *segmentRegistrar) startSendSegReg(ctx context.Context, wg *sync.WaitGroup) {
wg.Add(1)
go func() {
defer log.LogPanicAndExit()
defer log.HandlePanic()
defer wg.Done()
if err := r.msgr.SendSegReg(ctx, r.reg, r.addr, messenger.NextId()); err != nil {
r.logger.Error("[beaconing.Registrar] Unable to register segment",
Expand Down
2 changes: 1 addition & 1 deletion go/cs/ifstate/revoker.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func (p *brPusher) sendIfStateToBr(ctx context.Context, msg *path_mgmt.IFStateIn

wg.Add(1)
go func() {
defer log.LogPanicAndExit()
defer log.HandlePanic()
defer wg.Done()
if err := p.msgr.SendIfStateInfos(ctx, msg, a, messenger.NextId()); err != nil {
log.FromCtx(ctx).Error("Failed to send interface state to BR",
Expand Down
2 changes: 1 addition & 1 deletion go/cs/keepalive/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (h *handler) getIntfInfo() (common.IFIDType, *ifstate.Interface, error) {

func (h *handler) startPush(ifid common.IFIDType) {
go func() {
defer log.LogPanicAndExit()
defer log.HandlePanic()
ctx, cancelF := context.WithTimeout(context.Background(), IfStatePushTimeout)
defer cancelF()
h.tasks.IfStatePusher.Push(ctx, ifid)
Expand Down
4 changes: 2 additions & 2 deletions go/cs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func realMain() int {
}
defer log.Flush()
defer env.LogAppStopped(common.CPService, cfg.General.ID)
defer log.LogPanicAndExit()
defer log.HandlePanic()
if err := setup(); err != nil {
log.Crit("Setup failed", "err", err)
return 1
Expand Down Expand Up @@ -278,7 +278,7 @@ func realMain() int {
http.HandleFunc("/info", env.InfoHandler)
cfg.Metrics.StartPrometheus()
go func() {
defer log.LogPanicAndExit()
defer log.HandlePanic()
msgr.ListenAndServe()
}()

Expand Down
2 changes: 1 addition & 1 deletion go/examples/discovery_client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func realMain() int {
flag.Usage()
return 1
}
defer log.LogPanicAndExit()
defer log.HandlePanic()
if err := validateFlags(); err != nil {
log.Crit("Unable to validate flags", "err", err)
return 1
Expand Down
8 changes: 4 additions & 4 deletions go/examples/pingpong/pingpong.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func main() {
flag.Usage()
os.Exit(1)
}
defer log.LogPanicAndExit()
defer log.HandlePanic()
initNetwork()
switch *mode {
case ModeClient:
Expand Down Expand Up @@ -253,7 +253,7 @@ func (c *client) run() {
c.quicStream = newQuicStream(qstream)
log.Debug("Quic stream opened", "local", &local, "remote", &remote)
go func() {
defer log.LogPanicAndExit()
defer log.HandlePanic()
c.send()
}()
c.read()
Expand Down Expand Up @@ -380,7 +380,7 @@ func (s server) run() {
}
log.Info("Quic session accepted", "src", qsess.RemoteAddr())
go func() {
defer log.LogPanicAndExit()
defer log.HandlePanic()
s.handleClient(qsess)
}()
}
Expand Down Expand Up @@ -452,7 +452,7 @@ func setSignalHandler(closer io.Closer) {
c := make(chan os.Signal)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
go func() {
defer log.LogPanicAndExit()
defer log.HandlePanic()
<-c
closer.Close()
os.Exit(1)
Expand Down
2 changes: 1 addition & 1 deletion go/examples/pingpong/pp_integration/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func realMain() int {
fmt.Fprintf(os.Stderr, "Failed to init: %s\n", err)
return 1
}
defer log.LogPanicAndExit()
defer log.HandlePanic()
defer log.Flush()
cmnArgs := []string{"-sciondFromIA", "-log.console", "debug"}
clientArgs := []string{"-mode", "client", "-count", "1",
Expand Down
4 changes: 2 additions & 2 deletions go/godispatcher/dispatcher/dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ func NewServer(address string) (*Server, error) {
func (as *Server) Serve() error {
errChan := make(chan error)
go func() {
defer log.LogPanicAndExit()
defer log.HandlePanic()
netToRingDataplane := &NetToRingDataplane{
OverlayConn: as.ipv4Conn,
RoutingTable: as.routingTable,
}
errChan <- netToRingDataplane.Run()
}()
go func() {
defer log.LogPanicAndExit()
defer log.HandlePanic()
netToRingDataplane := &NetToRingDataplane{
OverlayConn: as.ipv6Conn,
RoutingTable: as.routingTable,
Expand Down
6 changes: 3 additions & 3 deletions go/godispatcher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func realMain() int {
}
defer log.Flush()
defer env.LogAppStopped("Dispatcher", cfg.Dispatcher.ID)
defer log.LogPanicAndExit()
defer log.HandlePanic()
if err := cfg.Validate(); err != nil {
log.Crit("Unable to validate config", "err", err)
return 1
Expand All @@ -75,7 +75,7 @@ func realMain() int {
}

go func() {
defer log.LogPanicAndExit()
defer log.HandlePanic()
err := RunDispatcher(
cfg.Dispatcher.DeleteSocket,
cfg.Dispatcher.ApplicationSocket,
Expand All @@ -88,7 +88,7 @@ func realMain() int {
}()
if cfg.Dispatcher.PerfData != "" {
go func() {
defer log.LogPanicAndExit()
defer log.HandlePanic()
err := http.ListenAndServe(cfg.Dispatcher.PerfData, nil)
if err != nil {
fatal.Fatal(err)
Expand Down
4 changes: 2 additions & 2 deletions go/godispatcher/network/app_socket.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (h *AppSocketServer) Handle(conn net.PacketConn) {
Logger: log.Root().New("clientID", fmt.Sprintf("%p", conn)),
}
go func() {
defer log.LogPanicAndExit()
defer log.HandlePanic()
ch.Handle(h.DispServer)
}()
}
Expand Down Expand Up @@ -84,7 +84,7 @@ func (h *AppConnHandler) Handle(appServer *dispatcher.Server) {
defer metrics.M.OpenSockets(metrics.SVC{Type: svc}).Dec()

go func() {
defer log.LogPanicAndExit()
defer log.HandlePanic()
h.RunRingToAppDataplane()
}()

Expand Down
4 changes: 2 additions & 2 deletions go/godispatcher/network/dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ func (d *Dispatcher) ListenAndServe() error {

errChan := make(chan error)
go func() {
defer log.LogPanicAndExit()
defer log.HandlePanic()
errChan <- dispServer.Serve()
}()

go func() {
defer log.LogPanicAndExit()
defer log.HandlePanic()
dispServer := &AppSocketServer{
Listener: dispServerConn,
DispServer: dispServer,
Expand Down
4 changes: 2 additions & 2 deletions go/hidden_path_srv/internal/hpsegreq/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ func (f *DefaultFetcher) Fetch(ctx context.Context,
for hps, ids := range mapping {
if hps.Equal(f.groupInfo.LocalIA) {
go func(ids []hiddenpath.GroupId) {
defer log.LogPanicAndExit()
defer log.HandlePanic()
f.fetchDB(ctx, ids, endsAt, replyChan)
}(ids)
} else {
go func(ids []hiddenpath.GroupId, hps addr.IA) {
defer log.LogPanicAndExit()
defer log.HandlePanic()
f.fetchRemote(ctx, ids, endsAt, hps, replyChan)
}(ids, hps)
}
Expand Down
2 changes: 1 addition & 1 deletion go/integration/cert_req/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func main() {
}

func realMain() int {
defer log.LogPanicAndExit()
defer log.HandlePanic()
defer log.Flush()
addFlags()
integration.Setup()
Expand Down
Loading

0 comments on commit 633b61b

Please sign in to comment.