Make sure the library compiles for windows
systemd sockets are not applicable for windows. However compilation should not fail on windows
This commit is contained in:
11
anyhttp.go
11
anyhttp.go
@@ -13,7 +13,6 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"syscall"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go.balki.me/anyhttp/idle"
|
"go.balki.me/anyhttp/idle"
|
||||||
@@ -150,16 +149,6 @@ func (u *UnixSocketConfig) GetListener() (net.Listener, error) {
|
|||||||
// StartFD is the starting file descriptor number
|
// StartFD is the starting file descriptor number
|
||||||
const StartFD = 3
|
const StartFD = 3
|
||||||
|
|
||||||
func makeFdListener(fd int, name string) (net.Listener, error) {
|
|
||||||
fdFile := os.NewFile(uintptr(fd), name)
|
|
||||||
l, err := net.FileListener(fdFile)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
syscall.CloseOnExec(fd)
|
|
||||||
return l, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetListener returns the FileListener created with socketed activated fd
|
// GetListener returns the FileListener created with socketed activated fd
|
||||||
func (s *SysdConfig) GetListener() (net.Listener, error) {
|
func (s *SysdConfig) GetListener() (net.Listener, error) {
|
||||||
|
|
||||||
|
19
fd_unix.go
Normal file
19
fd_unix.go
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
//go:build unix
|
||||||
|
|
||||||
|
package anyhttp
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net"
|
||||||
|
"os"
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
func makeFdListener(fd int, name string) (net.Listener, error) {
|
||||||
|
fdFile := os.NewFile(uintptr(fd), name)
|
||||||
|
l, err := net.FileListener(fdFile)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
syscall.CloseOnExec(fd)
|
||||||
|
return l, nil
|
||||||
|
}
|
10
fd_windows.go
Normal file
10
fd_windows.go
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package anyhttp
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"net"
|
||||||
|
)
|
||||||
|
|
||||||
|
func makeFdListener(fd int, name string) (net.Listener, error) {
|
||||||
|
return nil, errors.New("windows not supported")
|
||||||
|
}
|
Reference in New Issue
Block a user