3 Commits

Author SHA1 Message Date
80808310ce Make sure the library compiles for windows
systemd sockets are not applicable for windows. However compilation
should not fail on windows
2025-07-17 20:53:10 -04:00
97b73fb442 remove binary from git 2025-02-03 11:35:06 -05:00
42b8afc9da Remove log from test 2025-01-24 22:10:58 -05:00
5 changed files with 35 additions and 13 deletions

View File

@@ -13,7 +13,6 @@ import (
"strconv"
"strings"
"sync"
"syscall"
"time"
"go.balki.me/anyhttp/idle"
@@ -150,16 +149,6 @@ func (u *UnixSocketConfig) GetListener() (net.Listener, error) {
// StartFD is the starting file descriptor number
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
func (s *SysdConfig) GetListener() (net.Listener, error) {

View File

@@ -3,7 +3,6 @@ package anyhttp
import (
"context"
"encoding/json"
"log"
"testing"
"time"
)
@@ -123,7 +122,12 @@ func Test_parseAddress(t *testing.T) {
func TestServe(t *testing.T) {
ctx, err := Serve("unix?path=/tmp/foo.sock", nil)
log.Printf("Got ctx: %v\n, err: %v", ctx, err)
if err != nil {
t.Fatal()
}
if ctx.AddressType != UnixSocket {
t.Errorf("Serve() ServerCtx = %v, want %v", ctx.AddressType, UnixSocket)
}
ctx.Shutdown(context.TODO())
}

Binary file not shown.

19
fd_unix.go Normal file
View 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
View 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")
}