582
#endif /* NO_IPV6 */
583
584
585
-static void git_tcp_connect(int fd[2], char *host, int flags)
585
+/*
586
+ * Dummy child_process returned by git_connect() if the transport protocol
587
+ * does not need fork(2).
588
+ */
589
+static struct child_process no_fork = CHILD_PROCESS_INIT;
590
+
591
+int git_connection_is_socket(struct child_process *conn)
592
+{
593
+ return conn == &no_fork;
594
+}
595
+
596
+static struct child_process *git_tcp_connect(int fd[2], char *host, int flags)
597
{
598
int sockfd = git_tcp_connect_sock(host, flags);
599
600
fd[0] = sockfd;
601
fd[1] = dup(sockfd);
602
+
603
+ return &no_fork;
604
}
605
606
774
return protocol;
775
}
776
764
-static struct child_process no_fork = CHILD_PROCESS_INIT;
765
-
777
static const char *get_ssh_command(void)
778
{
779
const char *ssh;
862
}
863
864
/*
854
- * This returns a dummy child_process if the transport protocol does not
855
- * need fork(2), or a struct child_process object if it does. Once done,
856
- * finish the connection with finish_connect() with the value returned from
857
- * this function (it is safe to call finish_connect() with NULL to support
858
- * the former case).
865
+ * This returns the dummy child_process `no_fork` if the transport protocol
866
+ * does not need fork(2), or a struct child_process object if it does. Once
867
+ * done, finish the connection with finish_connect() with the value returned
868
+ * from this function (it is safe to call finish_connect() with NULL to
869
+ * support the former case).
870
*
871
* If it returns, the connect is successful; it just dies on errors (this
872
* will hopefully be changed in a libification effort, to return NULL when
876
const char *prog, int flags)
877
{
878
char *hostandport, *path;
868
- struct child_process *conn = &no_fork;
879
+ struct child_process *conn;
880
enum protocol protocol;
881
882
/* Without this we cannot rely on waitpid() to tell
912
if (git_use_proxy(hostandport))
913
conn = git_proxy_connect(fd, hostandport);
914
else
904
- git_tcp_connect(fd, hostandport, flags);
915
+ conn = git_tcp_connect(fd, hostandport, flags);
916
/*
917
* Separate original protocol components prog and path
918
* from extended host header with a NUL byte.
1052
return conn;
1053
}
1054
1044
-int git_connection_is_socket(struct child_process *conn)
1045
-{
1046
- return conn == &no_fork;
1047
-}
1048
-
1055
int finish_connect(struct child_process *conn)
1056
{
1057
int code;