Subject: Fix test failure socket-2.9: "1 {not owner}" instead of "1 {couldn't open socket address already in use}" by only setting returned error message if not jet set.

From: oehhar <[email-masked]>
Date: Tue, 1 Apr 2014 11:31:49 +0000

---
 generic/tclIO.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/generic/tclIO.c b/generic/tclIO.c
index 15fc8af..9e675c6 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -3211,18 +3211,17 @@ Tcl_Close(
 	}
 	return TCL_ERROR;
     }
-    if (result != 0) {
-	return TCL_ERROR;
-    }
     /*
-     * Bug 97069ea11a: set error message if a flush code is set
+     * Bug 97069ea11a: set error message if a flush code is set and no error
+     * message set up to now.
      */
-    if (flushcode != 0) {
+    if (flushcode != 0 && interp != NULL
+	    && 0 == Tcl_GetCharLength(Tcl_GetObjResult(interp)) ) {
 	Tcl_SetErrno(flushcode);
-	if (interp != NULL) {
-	    Tcl_SetObjResult(interp,
-			     Tcl_NewStringObj(Tcl_PosixError(interp), -1));
-	}
+	Tcl_SetObjResult(interp,
+		Tcl_NewStringObj(Tcl_PosixError(interp), -1));
+    }
+    if ((flushcode != 0) || (result != 0)) {
 	return TCL_ERROR;
     }
     return TCL_OK;
-- 
cgit v0.12