mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
picoev: bugfixes and UB mitigation (#18991)
This commit is contained in:
parent
2266ccecf3
commit
2fa177e310
@ -106,8 +106,6 @@ fn (mut pv Picoev) del(fd int) int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if pv.update_events(fd, picoev.picoev_del) != 0 {
|
if pv.update_events(fd, picoev.picoev_del) != 0 {
|
||||||
target.loop_id = -1
|
|
||||||
target.fd = 0
|
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,16 +147,21 @@ fn (mut pv Picoev) set_timeout(fd int, secs int) {
|
|||||||
// timeout event
|
// timeout event
|
||||||
[direct_array_access; inline]
|
[direct_array_access; inline]
|
||||||
fn (mut pv Picoev) handle_timeout() {
|
fn (mut pv Picoev) handle_timeout() {
|
||||||
|
mut to_remove := []int{}
|
||||||
|
|
||||||
for fd, timeout in pv.timeouts {
|
for fd, timeout in pv.timeouts {
|
||||||
if timeout <= pv.loop.now {
|
if timeout <= pv.loop.now {
|
||||||
|
to_remove << fd
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for fd in to_remove {
|
||||||
target := pv.file_descriptors[fd]
|
target := pv.file_descriptors[fd]
|
||||||
assert target.loop_id == pv.loop.id
|
assert target.loop_id == pv.loop.id
|
||||||
|
|
||||||
pv.timeouts.delete(fd)
|
pv.timeouts.delete(fd)
|
||||||
unsafe { target.cb(fd, picoev.picoev_timeout, &pv) }
|
unsafe { target.cb(fd, picoev.picoev_timeout, &pv) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// accept_callback accepts a new connection from `listen_fd` and adds it to the loop
|
// accept_callback accepts a new connection from `listen_fd` and adds it to the loop
|
||||||
fn accept_callback(listen_fd int, events int, cb_arg voidptr) {
|
fn accept_callback(listen_fd int, events int, cb_arg voidptr) {
|
||||||
|
Loading…
Reference in New Issue
Block a user