MCPcopy Index your code
hub / github.com/git/git / handle

Function handle

daemon.c:883–924  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

881
882static struct strvec cld_argv = STRVEC_INIT;
883static void handle(int incoming, struct sockaddr *addr, socklen_t addrlen)
884{
885 struct child_process cld = CHILD_PROCESS_INIT;
886
887 if (max_connections && live_children >= max_connections) {
888 kill_some_child();
889 sleep(1); /* give it some time to die */
890 check_dead_children();
891 if (live_children >= max_connections) {
892 close(incoming);
893 logerror("Too many children, dropping connection");
894 return;
895 }
896 }
897
898 if (addr->sa_family == AF_INET) {
899 char buf[128] = "";
900 struct sockaddr_in *sin_addr = (void *) addr;
901 inet_ntop(addr->sa_family, &sin_addr->sin_addr, buf, sizeof(buf));
902 strvec_pushf(&cld.env, "REMOTE_ADDR=%s", buf);
903 strvec_pushf(&cld.env, "REMOTE_PORT=%d",
904 ntohs(sin_addr->sin_port));
905#ifndef NO_IPV6
906 } else if (addr->sa_family == AF_INET6) {
907 char buf[128] = "";
908 struct sockaddr_in6 *sin6_addr = (void *) addr;
909 inet_ntop(AF_INET6, &sin6_addr->sin6_addr, buf, sizeof(buf));
910 strvec_pushf(&cld.env, "REMOTE_ADDR=[%s]", buf);
911 strvec_pushf(&cld.env, "REMOTE_PORT=%d",
912 ntohs(sin6_addr->sin6_port));
913#endif
914 }
915
916 strvec_pushv(&cld.args, cld_argv.v);
917 cld.in = incoming;
918 cld.out = dup(incoming);
919
920 if (start_command(&cld))
921 logerror("unable to fork");
922 else
923 add_child(&cld, addr, addrlen);
924}
925
926static void child_handler(int signo UNUSED)
927{

Callers 1

service_loopFunction · 0.85

Calls 9

kill_some_childFunction · 0.85
sleepFunction · 0.85
check_dead_childrenFunction · 0.85
logerrorFunction · 0.85
inet_ntopFunction · 0.85
strvec_pushfFunction · 0.85
strvec_pushvFunction · 0.85
start_commandFunction · 0.85
add_childFunction · 0.70

Tested by

no test coverage detected