Overview
| Artifact ID: | 2b568e9a235d4d6a859ceaebf641e12efb39ffbfd76c408300cbd47f979fc577 |
|---|---|
| Ticket: | c6897e6e6a8a65a995ec35c9c297b926bf1b6783
select notifier crashes/misbehaves on fd >= FD_SETSIZE |
| User & Date: | chw on 2019-11-10 19:17:54 |
Changes
- icomment:
The OP's script needs some small mods due to startup conditions and due to two problems which can occur: 1. fd >= FD_SETSIZE and 2. hit of errno == EMFILE. Since each iteration requires two fds (one for the client and one for the accepted socket) it depends if an even or odd number of fds was in use when the script performs its very first step. --- 8< --- #!/usr/bin/env tclsh # uncomment for odd/even start condition. # open /dev/null proc dummy_server {sock} { puts -nonewline stderr "S" close $sock } proc dummy_client {sock} { puts -nonewline stderr "C" close $sock # consume one file descriptor for a while after 1 [list close [open /dev/null]] } proc accept_one {sock addr port} { fileevent $sock readable [list dummy_server $sock] puts -nonewline stderr "+" } proc crashme {count} { puts -nonewline stderr "connecting $count sockets " set listener [socket -server accept_one 0] # non-blocking listen socket, else accept can block chan configure $listener -blocking 0 lassign [chan configure $listener -sockname] listenIp listenHost listenPort for {set i 0} {$i < $count} {incr i} { set client [socket -async $listenIp $listenPort] fileevent $client readable [list dummy_client $client] puts -nonewline stderr "." update } puts stderr " done." } if {!$tcl_interactive} { crashme [lindex $::argv 0] } --- 8< --- - login: "chw"
- mimetype: "text/plain"