Skip to content

Commit 7ffe853

Browse files
peffgitster
authored andcommitted
connect: let callers know if connection is a socket
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5cbf824 commit 7ffe853

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

cache.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,7 @@ extern struct ref *find_ref_by_name(const struct ref *list, const char *name);
865865
#define CONNECT_VERBOSE (1u << 0)
866866
extern struct child_process *git_connect(int fd[2], const char *url, const char *prog, int flags);
867867
extern int finish_connect(struct child_process *conn);
868+
extern int git_connection_is_socket(struct child_process *conn);
868869
extern int path_match(const char *path, int nr, char **match);
869870
struct extra_have_objects {
870871
int nr, alloc;

connect.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,10 +633,15 @@ struct child_process *git_connect(int fd[2], const char *url_orig,
633633
return conn;
634634
}
635635

636+
int git_connection_is_socket(struct child_process *conn)
637+
{
638+
return conn == &no_fork;
639+
}
640+
636641
int finish_connect(struct child_process *conn)
637642
{
638643
int code;
639-
if (!conn || conn == &no_fork)
644+
if (!conn || git_connection_is_socket(conn))
640645
return 0;
641646

642647
code = finish_command(conn);

0 commit comments

Comments
 (0)