/[tcldrop]/tcldrop/modules/conn.tcl
ViewVC logotype

Diff of /tcldrop/modules/conn.tcl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.9 by fireegl, Tue Dec 2 09:01:46 2003 UTC revision 1.10 by fireegl, Wed Dec 3 01:20:16 2003 UTC
# Line 32  Line 32 
32  namespace eval ::tcldrop::conn {  namespace eval ::tcldrop::conn {
33          variable version {0.7}          variable version {0.7}
34          package provide tcldrop::conn $version          package provide tcldrop::conn $version
35          variable rcsid {$Id}          variable rcsid {$Id$}
36          variable Defaults          variable Defaults
37          if {![info exists ::my-ip]} { set ::my-ip {} }          if {![info exists ::my-ip]} { set ::my-ip {} }
38          set Defaults(global) [list {async} {1} {buffering} {line} {myaddr} ${::my-ip} {blocking} {0} {timeout} {237}]          set Defaults(global) [list {async} {1} {buffering} {line} {myaddr} ${::my-ip} {blocking} {0} {timeout} {237}]
# Line 130  proc ::tcldrop::conn::control {idx comma Line 130  proc ::tcldrop::conn::control {idx comma
130  proc ::tcldrop::conn::Read {idx} {  proc ::tcldrop::conn::Read {idx} {
131          foreach {a d} [::tcldrop::idx::Info $idx] { array set idxinfo $d }          foreach {a d} [::tcldrop::idx::Info $idx] { array set idxinfo $d }
132          if {![info exists idxinfo(control)]} { return }          if {![info exists idxinfo(control)]} { return }
133          # For speed, we read in all available lines (This is absolutely necessary when running inside an Eggdrop, because Eggdrop's event loops are 1 second apart.):          if {[set error [fconfigure $idxinfo(sock) -error]] != {}} {
134          if {![catch { read -nonewline $idxinfo(sock) } lines]} {                  putloglev d * "net: error!(connect) idx $idx  (${error})"
135                  foreach line [split $lines \n] {                  # Send {} to the control proc and kill the sock/idx.
136                          $idxinfo(control) $idx $line                  # Note, A check on valididx (from the control proc) is one way to tell wether or not an EOF has actually been received.
137                          # The update is here so that one connection can't be flooded and drown                  catch { killutimer $idxinfo(connecttimer) }
138                          # out the other connections and therefore making them less responsive.                  $idxinfo(control) $idx {}
139                          # At least that's what I hope it's good for.  =)                  killidx $idx
140                          update          } elseif {[eof $idxinfo(sock)]} {
                 }  
         } else {  
141                  putloglev d * "net: eof!(read) idx $idx"                  putloglev d * "net: eof!(read) idx $idx"
142                  # Send {} to the control proc and kill the sock/idx.                  # Send {} to the control proc and kill the sock/idx.
143                  # Note, A check on valididx (from the control proc) is one way to tell wether or not an EOF has actually been received.                  # Note, A check on valididx (from the control proc) is one way to tell wether or not an EOF has actually been received.
144                  $idxinfo(control) $idx {}                  $idxinfo(control) $idx {}
145                  killidx $idx                  killidx $idx
146            } else {
147                    # For speed, we read in all available lines (This is absolutely necessary when running inside an Eggdrop, because Eggdrop's event loops are 1 second apart.):
148                    while {[gets $idxinfo(sock) line] >= 1} { $idxinfo(control) $idx $line }
149          }          }
150  }  }
151    
# Line 157  proc ::tcldrop::conn::Write {idx} { Line 158  proc ::tcldrop::conn::Write {idx} {
158    
159  proc ::tcldrop::conn::ConnectTimeout {idx} {  proc ::tcldrop::conn::ConnectTimeout {idx} {
160          putloglev d * "net: timeout!(connect) idx $idx"          putloglev d * "net: timeout!(connect) idx $idx"
161            foreach {a d} [::tcldrop::idx::Info $idx] { array set idxinfo $d }
162            catch { killutimer $idxinfo(connecttimer) }
163            catch { fileevent $idxinfo(sock) writable {} }
164          killidx $idx          killidx $idx
165  }  }

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26