Blame SOURCES/libtirpc-0.2.4-clnt-mthr-create.patch

b39f54
diff --git a/src/clnt_vc.c b/src/clnt_vc.c
b39f54
index 61264d4..ebe28f8 100644
b39f54
--- a/src/clnt_vc.c
b39f54
+++ b/src/clnt_vc.c
b39f54
@@ -72,6 +72,8 @@
b39f54
 #define CMGROUP_MAX    16
b39f54
 #define SCM_CREDS      0x03            /* process creds (struct cmsgcred) */
b39f54
 
b39f54
+#undef rpc_createerr                   /* make it clear it is a thread safe variable */
b39f54
+
b39f54
 /*
b39f54
  * Credentials structure, used to verify the identity of a peer
b39f54
  * process that has sent us a message. This is allocated by the
b39f54
@@ -188,10 +190,11 @@ clnt_vc_create(fd, raddr, prog, vers, sendsz, recvsz)
b39f54
 	cl = (CLIENT *)mem_alloc(sizeof (*cl));
b39f54
 	ct = (struct ct_data *)mem_alloc(sizeof (*ct));
b39f54
 	if ((cl == (CLIENT *)NULL) || (ct == (struct ct_data *)NULL)) {
b39f54
+		struct rpc_createerr *ce = &get_rpc_createerr();
b39f54
+		ce->cf_stat = RPC_SYSTEMERROR;
b39f54
+		ce->cf_error.re_errno = errno;
b39f54
 		(void) syslog(LOG_ERR, clnt_vc_errstr,
b39f54
 		    clnt_vc_str, __no_mem_str);
b39f54
-		rpc_createerr.cf_stat = RPC_SYSTEMERROR;
b39f54
-		rpc_createerr.cf_error.re_errno = errno;
b39f54
 		goto err;
b39f54
 	}
b39f54
 	ct->ct_addr.buf = NULL;
b39f54
@@ -230,26 +233,29 @@ clnt_vc_create(fd, raddr, prog, vers, sendsz, recvsz)
b39f54
 		assert(vc_cv != (cond_t *) NULL);
b39f54
 
b39f54
 	/*
b39f54
-	 * XXX - fvdl connecting while holding a mutex?
b39f54
+	 * Do not hold mutex during connect
b39f54
 	 */
b39f54
+	mutex_unlock(&clnt_fd_lock);
b39f54
+
b39f54
 	slen = sizeof ss;
b39f54
 	if (getpeername(fd, (struct sockaddr *)&ss, &slen) < 0) {
b39f54
 		if (errno != ENOTCONN) {
b39f54
-			rpc_createerr.cf_stat = RPC_SYSTEMERROR;
b39f54
-			rpc_createerr.cf_error.re_errno = errno;
b39f54
-			mutex_unlock(&clnt_fd_lock);
b39f54
+			struct rpc_createerr *ce = &get_rpc_createerr();
b39f54
+			ce->cf_stat = RPC_SYSTEMERROR;
b39f54
+			ce->cf_error.re_errno = errno;
b39f54
 			thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
b39f54
 			goto err;
b39f54
 		}
b39f54
 		if (connect(fd, (struct sockaddr *)raddr->buf, raddr->len) < 0){
b39f54
-			rpc_createerr.cf_stat = RPC_SYSTEMERROR;
b39f54
-			rpc_createerr.cf_error.re_errno = errno;
b39f54
-			mutex_unlock(&clnt_fd_lock);
b39f54
-			thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
b39f54
-			goto err;
b39f54
+			if (errno != EISCONN) {
b39f54
+				struct rpc_createerr *ce = &get_rpc_createerr();
b39f54
+				ce->cf_stat = RPC_SYSTEMERROR;
b39f54
+				ce->cf_error.re_errno = errno;
b39f54
+				thr_sigsetmask(SIG_SETMASK, &(mask), NULL);
b39f54
+				goto err;
b39f54
+			}
b39f54
 		}
b39f54
 	}
b39f54
-	mutex_unlock(&clnt_fd_lock);
b39f54
 	if (!__rpc_fd2sockinfo(fd, &si))
b39f54
 		goto err;
b39f54
 	thr_sigsetmask(SIG_SETMASK, &(mask), NULL);