I have multiple listeners (like two listening on port :8080 and 8081 and one listening to https on 443 port). That means I have now three listeners. However the nature of goagain doesn't allow to use it with several listeners. I can split my app that it runs like three binaries but this would be not a good choice.
for addr, l := range listeners {
a := reflect.ValueOf(l)
v := a.Elem().FieldByName("fd").Elem()
fd := uintptr(v.FieldByName("sysfd").Int())
if err := os.Setenv("GOAGAIN_FD"+addr, fmt.Sprint(fd)); nil != err {
return err
}
if err := os.Setenv("GOAGAIN_NAME"+addr, fmt.Sprintf("tcp:%s->", l.Addr().String())); nil != err {
return err
}
fmt.Println("FD number is", fd)
files[fd] = os.NewFile(fd, string(v.FieldByName("sysfile").String()))
}
However I don't like the way the file descriptors are created. Because I have to create the array earlier to append the FD's to the files
arary, like:
files := make([]*os.File, 30 )
Here, 30 is just an integer that's large enough. I've tried to use append
on files
array. However when I use append it's breaking goagain with this err:
fork/exec ./go/bin/test_goagain: bad file descriptor
It seems it is working quite well. Do you have any plans to support multiple listeners?