[Tkabber-dev] r1280 - in trunk/tkabber: . jabberlib

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Wed Oct 24 19:14:43 MSD 2007


Author: sergei
Date: 2007-10-24 19:14:42 +0400 (Wed, 24 Oct 2007)
New Revision: 1280

Modified:
   trunk/tkabber/ChangeLog
   trunk/tkabber/jabberlib/autoconnect.tcl
   trunk/tkabber/jabberlib/https.tcl
   trunk/tkabber/jabberlib/socks4.tcl
   trunk/tkabber/jabberlib/socks5.tcl
Log:
	* jabberlib/https.tcl, jabberlib/socks3.tcl, jabberlib/socks5.tcl,
	  jabberlib/autoconnect.tcl: Fixed closing TCP socket to a proxy in
	  case of network problems.


Modified: trunk/tkabber/ChangeLog
===================================================================
--- trunk/tkabber/ChangeLog	2007-10-23 17:04:23 UTC (rev 1279)
+++ trunk/tkabber/ChangeLog	2007-10-24 15:14:42 UTC (rev 1280)
@@ -1,3 +1,9 @@
+2007-10-24  Sergei Golovan  <sgolovan at nes.ru>
+
+	* jabberlib/https.tcl, jabberlib/socks3.tcl, jabberlib/socks5.tcl,
+	  jabberlib/autoconnect.tcl: Fixed closing TCP socket to a proxy in
+	  case of network problems.
+
 2007-10-21  Sergei Golovan  <sgolovan at nes.ru>
 
 	* plugins/richtext/emoticons.tcl: Added support for JISP emoticon

Modified: trunk/tkabber/jabberlib/autoconnect.tcl
===================================================================
--- trunk/tkabber/jabberlib/autoconnect.tcl	2007-10-23 17:04:23 UTC (rev 1279)
+++ trunk/tkabber/jabberlib/autoconnect.tcl	2007-10-24 15:14:42 UTC (rev 1280)
@@ -109,6 +109,9 @@
     # Connect ahost + aport.
     set sock [::socket -async $ahost $aport]
     set token [namespace current]::$sock
+    fconfigure $sock -blocking 0
+    fileevent $sock writable [namespace code [list writable $token]]
+
     variable $token
     upvar 0 $token state
 
@@ -117,9 +120,6 @@
     set state(sock) $sock
     set state(cmd)  $argsA(-command)
 
-    fconfigure $sock -blocking 0
-    fileevent $sock writable [namespace code [list writable $token]]
-
     if {[string length $state(cmd)]} {
 	return
     } else {
@@ -132,6 +132,7 @@
 	if {[string equal $status OK]} {
 	    return $sock
 	} else {
+	    catch {close $sock}
 	    return -code error $sock
 	}
     }
@@ -162,13 +163,12 @@
     set sock $state(sock)
     fileevent $sock writable {}
 
-    if {[catch {eof $sock} iseof] || $iseof} {
+    if {[catch {fconfigure $sock -peername}]} {
 	Finish $token network-failure
     } else {
 	if {[string length $proxy]} {
 	    eval {${proxy}::connect $sock $state(host) $state(port) \
-		      -command [namespace code [list SocksCb $token]]
-		} [get_opts]
+		      -command [namespace code [list SocksCb $token]]} [get_opts]
 	} else {
 	    Finish $token
 	}

Modified: trunk/tkabber/jabberlib/https.tcl
===================================================================
--- trunk/tkabber/jabberlib/https.tcl	2007-10-23 17:04:23 UTC (rev 1279)
+++ trunk/tkabber/jabberlib/https.tcl	2007-10-24 15:14:42 UTC (rev 1280)
@@ -74,6 +74,7 @@
     }
 
     if {[catch {set state(peer) [fconfigure $sock -peername]}]} {
+	catch {close $sock}
 	if {$state(async)} {
 	    after idle [list $state(-command) ERROR network-failure]
 	    Free $token
@@ -107,6 +108,7 @@
 	if {[string equal $status OK]} {
 	    return $sock
 	} else {
+	    catch {close $sock}
 	    return -code error $sock
 	}
     }

Modified: trunk/tkabber/jabberlib/socks4.tcl
===================================================================
--- trunk/tkabber/jabberlib/socks4.tcl	2007-10-23 17:04:23 UTC (rev 1279)
+++ trunk/tkabber/jabberlib/socks4.tcl	2007-10-24 15:14:42 UTC (rev 1280)
@@ -104,6 +104,7 @@
 	puts -nonewline $sock $bdata
 	flush $sock
     } err]} {
+	catch {close $sock}
 	if {$state(async)} {
 	    after idle [list $state(-command) ERROR network-failure]
 	    Free $token
@@ -135,6 +136,7 @@
 	if {[string equal $status OK]} {
 	    return $sock
 	} else {
+	    catch {close $sock}
 	    return -code error $sock
 	}
     }

Modified: trunk/tkabber/jabberlib/socks5.tcl
===================================================================
--- trunk/tkabber/jabberlib/socks5.tcl	2007-10-23 17:04:23 UTC (rev 1279)
+++ trunk/tkabber/jabberlib/socks5.tcl	2007-10-24 15:14:42 UTC (rev 1280)
@@ -163,6 +163,7 @@
 	puts -nonewline $sock "$const(ver)$nmethods$methods"
 	flush $sock
     } err]} {
+	catch {close $sock}
 	if {$state(async)} {
 	    after idle [list $state(-command) ERROR network-failure]
 	    Free $token
@@ -194,6 +195,7 @@
 	if {[string equal $status OK]} {
 	    return $sock
 	} else {
+	    catch {close $sock}
 	    return -code error $sock
 	}
     }



More information about the Tkabber-dev mailing list