No funny names on cygwin...
[git.git] / daemon.c
index 8366a33..11fa3ed 100644 (file)
--- a/daemon.c
+++ b/daemon.c
@@ -1,6 +1,5 @@
 #include "cache.h"
 #include "pkt-line.h"
-#include <alloca.h>
 #include <signal.h>
 #include <sys/wait.h>
 #include <sys/socket.h>
@@ -143,7 +142,7 @@ static int upload(char *dir, int dirlen)
         * is ok with us doing this.
         */
        if ((!export_all_trees && access("git-daemon-export-ok", F_OK)) ||
-           access("objects/00", X_OK) ||
+           access("objects/", X_OK) ||
            access("HEAD", R_OK)) {
                logerror("Not a valid git-daemon-enabled repository: '%s'", dir);
                return -1;
@@ -464,9 +463,7 @@ static int socksetup(int port, int **socklist_p)
                return 0;
        }
 
-       *socklist_p = malloc(sizeof(int));
-       if ( !*socklist_p )
-               die("memory allocation failed: %s", strerror(errno));
+       *socklist_p = xmalloc(sizeof(int));
        **socklist_p = sockfd;
 }
 
@@ -477,14 +474,14 @@ static int service_loop(int socknum, int *socklist)
        struct pollfd *pfd;
        int i;
 
-       pfd = calloc(socknum, sizeof(struct pollfd));
-       if (!pfd)
-               die("memory allocation failed: %s", strerror(errno));
+       pfd = xcalloc(socknum, sizeof(struct pollfd));
 
        for (i = 0; i < socknum; i++) {
                pfd[i].fd = socklist[i];
                pfd[i].events = POLLIN;
        }
+
+       signal(SIGCHLD, child_handler);
        
        for (;;) {
                int i;
@@ -501,7 +498,7 @@ static int service_loop(int socknum, int *socklist)
                for (i = 0; i < socknum; i++) {
                        if (pfd[i].revents & POLLIN) {
                                struct sockaddr_storage ss;
-                               int sslen = sizeof(ss);
+                               unsigned int sslen = sizeof(ss);
                                int incoming = accept(pfd[i].fd, (struct sockaddr *)&ss, &sslen);
                                if (incoming < 0) {
                                        switch (errno) {
@@ -523,8 +520,6 @@ static int serve(int port)
 {
        int socknum, *socklist;
        
-       signal(SIGCHLD, child_handler);
-       
        socknum = socksetup(port, &socklist);
        if (socknum == 0)
                die("unable to allocate any listen sockets on port %u", port);