Skip to content

Commit

Permalink
clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
cheng-zhongliang committed Oct 26, 2023
1 parent 0fb6ac8 commit 3e4c360
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 10 deletions.
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,14 @@ func main() {
if err != nil {
panic(err)
}

fd := socket()
ev := event.New(base, fd, event.EvRead|event.EvPersist, accept, base)
if err := ev.Attach(0); err != nil {
panic(err)
}

if err := base.Dispatch(); err != nil && err != syscall.EBADF {
panic(err)
}

syscall.Close(fd)
}

Expand All @@ -153,12 +150,10 @@ func socket() int {

func accept(fd int, events uint32, arg interface{}) {
base := arg.(*event.EventBase)

clientFd, _, err := syscall.Accept(fd)
if err != nil {
panic(err)
}

ev := event.New(base, clientFd, event.EvRead|event.EvPersist, echo, nil)
if err := ev.Attach(0); err != nil {
panic(err)
Expand Down
5 changes: 0 additions & 5 deletions examples/echo_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,14 @@ func main() {
if err != nil {
panic(err)
}

fd := socket()
ev := event.New(base, fd, event.EvRead|event.EvPersist, accept, base)
if err := ev.Attach(0); err != nil {
panic(err)
}

if err := base.Dispatch(); err != nil && err != syscall.EBADF {
panic(err)
}

syscall.Close(fd)
}

Expand All @@ -43,12 +40,10 @@ func socket() int {

func accept(fd int, events uint32, arg interface{}) {
base := arg.(*event.EventBase)

clientFd, _, err := syscall.Accept(fd)
if err != nil {
panic(err)
}

ev := event.New(base, clientFd, event.EvRead|event.EvPersist, echo, nil)
if err := ev.Attach(0); err != nil {
panic(err)
Expand Down

0 comments on commit 3e4c360

Please sign in to comment.