summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 026aa93)
raw | patch | inline | side by side (parent: 026aa93)
author | Junio C Hamano <junkio@cox.net> | |
Mon, 22 Jan 2007 01:10:51 +0000 (17:10 -0800) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Mon, 22 Jan 2007 05:51:01 +0000 (21:51 -0800) |
Earlier, git_connect() returned the same fd twice or two
separate fds, depending on the way the connection was made (when
we are talking to the other end over a single socket, we used
the same fd twice, and when our end is connected to a pipepair
we used two).
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. Many were
closing the same fd twice when we are talking over a single
socket, and one was leaking a fd.
This fixes it to uniformly use two separate fds, 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@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
separate fds, depending on the way the connection was made (when
we are talking to the other end over a single socket, we used
the same fd twice, and when our end is connected to a pipepair
we used two).
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. Many were
closing the same fd twice when we are talking over a single
socket, and one was leaking a fd.
This fixes it to uniformly use two separate fds, 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@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
builtin-archive.c | patch | blob | history | |
connect.c | patch | blob | history |
diff --git a/builtin-archive.c b/builtin-archive.c
index 32737d31621e8d1a900d944f97fcaae43d56a12e..f613ac25164beadb4874d8a07b6bbac62796a530 100644 (file)
--- a/builtin-archive.c
+++ b/builtin-archive.c
/* Now, start reading from fd[0] and spit it out to stdout */
rv = recv_sideband("archive", fd[0], 1, 2);
close(fd[0]);
+ close(fd[1]);
rv |= finish_connect(pid);
return !!rv;
diff --git a/connect.c b/connect.c
index 66daa11a5737efd6ee2dbd6ff2ad0e1475fcba20..78448889da3f11fa28aacad17d3044a1c0df7e54 100644 (file)
--- a/connect.c
+++ b/connect.c
int sockfd = git_tcp_connect_sock(host);
fd[0] = sockfd;
- fd[1] = sockfd;
+ fd[1] = dup(sockfd);
}