mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
picoev: fix for windows apps with veb in a thread, parallel to a webview, that opens a lot of file descriptors (#23492)
This commit is contained in:
parent
d23e70f546
commit
d5aa37d8b7
3 changed files with 20 additions and 5 deletions
6
vlib/picoev/constants_default.c.v
Normal file
6
vlib/picoev/constants_default.c.v
Normal file
|
@ -0,0 +1,6 @@
|
|||
module picoev
|
||||
|
||||
// max_fds is the maximum number of file descriptors that can be managed.
|
||||
// Many sizes depend on it, and some internal arrays are also iterated based on it,
|
||||
// so increasing it a lot can slow down looping :-| .
|
||||
pub const max_fds = 1024
|
11
vlib/picoev/constants_windows.c.v
Normal file
11
vlib/picoev/constants_windows.c.v
Normal file
|
@ -0,0 +1,11 @@
|
|||
module picoev
|
||||
|
||||
// max_fds is the maximum number of file descriptors that can be managed.
|
||||
// Many sizes depend on it, and some internal arrays are also iterated based on it,
|
||||
// so increasing it a lot can slow down looping :-| .
|
||||
// It is higher on windows, because if you start a veb/picoev webservice in a thread,
|
||||
// the returned file descriptors can be higher than 1024 in value, especially if you
|
||||
// also have a webview running in another thread, that also opens its own file descriptors.
|
||||
// Note: this works, because on windows we use select, and select on win32,
|
||||
// is not limited to polling on only 1024 fds.
|
||||
pub const max_fds = 4096
|
|
@ -4,9 +4,6 @@ import net
|
|||
import picohttpparser
|
||||
import time
|
||||
|
||||
// maximum number of file descriptors that can be managed
|
||||
pub const max_fds = 1024
|
||||
|
||||
// maximum size of the event queue
|
||||
pub const max_queue = 4096
|
||||
|
||||
|
@ -70,12 +67,12 @@ pub struct Picoev {
|
|||
max_write int = 8192
|
||||
mut:
|
||||
loop &LoopType = unsafe { nil }
|
||||
file_descriptors [max_fds]&Target
|
||||
file_descriptors [4096]&Target // TODO: use max_fds here, instead of the hardcoded size, when the compiler allows it
|
||||
timeouts map[int]i64
|
||||
num_loops int
|
||||
|
||||
buf &u8 = unsafe { nil }
|
||||
idx [1024]int
|
||||
idx [max_fds]int
|
||||
out &u8 = unsafe { nil }
|
||||
|
||||
date string
|
||||
|
@ -192,6 +189,7 @@ fn accept_callback(listen_fd int, events int, cb_arg voidptr) {
|
|||
}
|
||||
if accepted_fd >= max_fds {
|
||||
// should never happen
|
||||
elog('Error during accept, accepted_fd >= max_fd')
|
||||
close_socket(accepted_fd)
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue