[PATCH] Make sure git_connect() always give two file descriptors.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Earlier, git_connect() returned the same fd when the destination
was remote (i.e.  we used socket to communicate with it) and two
separate fds when the destination was local (i.e. we used
pipe(2)).

This forced callers who do close() and dup() to really care
which was which, and most of the existing callers got this
wrong, although without much visible ill effect.

Fix it to uniformly use two separate fd, so if somebody wants to
close only reader side can just do close() on it without
worrying about it accidentally also closing the writer side or
vice versa.

Signed-off-by: Linus Torvalds <torvalds@xxxxxxxx>
Signed-off-by: Junio C Hamano <junkio@xxxxxxx>
---

 * Your patch; just checking if the above log message makes sense...

 connect.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/connect.c b/connect.c
index 66daa11..7844888 100644
--- a/connect.c
+++ b/connect.c
@@ -529,7 +529,7 @@ static void git_tcp_connect(int fd[2], char *host)
 	int sockfd = git_tcp_connect_sock(host);
 
 	fd[0] = sockfd;
-	fd[1] = sockfd;
+	fd[1] = dup(sockfd);
 }
 
 
-- 
1.5.0.rc2


-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]