Skip to content

Commit

Permalink
connect: let callers know if connection is a socket
Browse files Browse the repository at this point in the history
They might care because they want to do a half-duplex close.
With pipes, that means simply closing the output descriptor;
with a socket, you must actually call shutdown.

Instead of exposing the magic no_fork child_process struct,
let's encapsulate the test in a function.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jeff King authored and Junio C Hamano committed May 16, 2011
1 parent 5cbf824 commit 7ffe853
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,7 @@ extern struct ref *find_ref_by_name(const struct ref *list, const char *name);
#define CONNECT_VERBOSE (1u << 0)
extern struct child_process *git_connect(int fd[2], const char *url, const char *prog, int flags);
extern int finish_connect(struct child_process *conn);
extern int git_connection_is_socket(struct child_process *conn);
extern int path_match(const char *path, int nr, char **match);
struct extra_have_objects {
int nr, alloc;
Expand Down
7 changes: 6 additions & 1 deletion connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -633,10 +633,15 @@ struct child_process *git_connect(int fd[2], const char *url_orig,
return conn;
}

int git_connection_is_socket(struct child_process *conn)
{
return conn == &no_fork;
}

int finish_connect(struct child_process *conn)
{
int code;
if (!conn || conn == &no_fork)
if (!conn || git_connection_is_socket(conn))
return 0;

code = finish_command(conn);
Expand Down

0 comments on commit 7ffe853

Please sign in to comment.