Skip to content

Commit

Permalink
increate max path length for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Casper64 committed Nov 10, 2023
1 parent d4b3056 commit cdc359d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
8 changes: 6 additions & 2 deletions vlib/net/unix/aasocket.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ import net

const use_net = net.no_timeout

// 104 for macos, 108 for linux => use the minimum
const max_sun_path = 104
const max_sun_path = $if windows {
256
} $else {
// 104 for macos, 108 for linux => use the minimum
104
}

// Select represents a select operation
enum Select {
Expand Down
5 changes: 1 addition & 4 deletions vlib/net/unix/common.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,9 @@ fn wait_for_common(handle int, deadline time.Time, timeout time.Duration, test S
// Convert timeouts to deadlines
real_deadline := if timeout == net.infinite_timeout {
time.unix(0)
} else if timeout == 0 {
} else if timeout <= 0 {
// No timeout set, so assume deadline
deadline
} else if timeout < 0 {
// TODO(emily): Do something nicer here :)
panic('invalid negative timeout')
} else {
// timeout
time.now().add(timeout)
Expand Down
14 changes: 9 additions & 5 deletions vlib/net/unix/unix_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import os
import net.unix

const (
tfolder = os.join_path(os.vtmp_dir(), 'unix_test')
test_port = os.join_path(tfolder, 'unix_domain_socket')
tfolder = os.join_path(os.vtmp_dir(), 'unix_test')
socket_path = os.join_path(tfolder, 'v_unix.sock')
)

fn testsuite_begin() {
Expand Down Expand Up @@ -36,7 +36,7 @@ fn echo_server(mut l unix.StreamListener) ! {
}

fn echo() ! {
mut c := unix.connect_stream(test_port)!
mut c := unix.connect_stream(socket_path)!
defer {
c.close() or {}
}
Expand All @@ -53,9 +53,13 @@ fn echo() ! {
}

fn test_tcp() {
assert os.exists(test_port) == false
mut l := unix.listen_stream(test_port) or { panic(err) }
assert os.exists(socket_path) == false

mut l := unix.listen_stream(socket_path) or { panic(err) }
spawn echo_server(mut l)
echo() or { panic(err) }
l.close() or {}

// test if socket file is removed/unlinked
assert os.exists(socket_path) == false
}

0 comments on commit cdc359d

Please sign in to comment.