projects
/
git.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Allow finding things that begin with a dash in 'git grep'
[git.git]
/
daemon.c
diff --git
a/daemon.c
b/daemon.c
index
eeff9e7
..
5100cf2
100644
(file)
--- a/
daemon.c
+++ b/
daemon.c
@@
-3,6
+3,7
@@
#include <signal.h>
#include <sys/wait.h>
#include <sys/socket.h>
#include <signal.h>
#include <sys/wait.h>
#include <sys/socket.h>
+#include <sys/time.h>
#include <netdb.h>
#include <netinet/in.h>
#include <netdb.h>
#include <netinet/in.h>
@@
-71,19
+72,19
@@
static int max_connections = 25;
/* These are updated by the signal handler */
static volatile unsigned int children_reaped = 0;
/* These are updated by the signal handler */
static volatile unsigned int children_reaped = 0;
-pid_t dead_child[MAX_CHILDREN];
+
static
pid_t dead_child[MAX_CHILDREN];
/* These are updated by the main loop */
static unsigned int children_spawned = 0;
static unsigned int children_deleted = 0;
/* These are updated by the main loop */
static unsigned int children_spawned = 0;
static unsigned int children_deleted = 0;
-struct child {
+st
atic st
ruct child {
pid_t pid;
pid_t pid;
-
socklen_
t addrlen;
+
in
t addrlen;
struct sockaddr_storage address;
} live_child[MAX_CHILDREN];
struct sockaddr_storage address;
} live_child[MAX_CHILDREN];
-static void add_child(int idx, pid_t pid, struct sockaddr *addr,
socklen_
t addrlen)
+static void add_child(int idx, pid_t pid, struct sockaddr *addr,
in
t addrlen)
{
live_child[idx].pid = pid;
live_child[idx].addrlen = addrlen;
{
live_child[idx].pid = pid;
live_child[idx].addrlen = addrlen;
@@
-177,7
+178,7
@@
static void check_max_connections(void)
}
}
}
}
-static void handle(int incoming, struct sockaddr *addr,
socklen_
t addrlen)
+static void handle(int incoming, struct sockaddr *addr,
in
t addrlen)
{
pid_t pid = fork();
{
pid_t pid = fork();
@@
-294,8
+295,11
@@
static int serve(int port)
fds = fds_init;
if (select(maxfd + 1, &fds, NULL, NULL, NULL) < 0) {
fds = fds_init;
if (select(maxfd + 1, &fds, NULL, NULL, NULL) < 0) {
- error("select failed, resuming: %s", strerror(errno));
- sleep(1);
+ if (errno != EINTR) {
+ error("select failed, resuming: %s",
+ strerror(errno));
+ sleep(1);
+ }
continue;
}
continue;
}
@@
-304,7
+308,7
@@
static int serve(int port)
if (FD_ISSET(sockfd, &fds)) {
struct sockaddr_storage ss;
if (FD_ISSET(sockfd, &fds)) {
struct sockaddr_storage ss;
-
socklen_
t sslen = sizeof(ss);
+
in
t sslen = sizeof(ss);
int incoming = accept(sockfd, (struct sockaddr *)&ss, &sslen);
if (incoming < 0) {
switch (errno) {
int incoming = accept(sockfd, (struct sockaddr *)&ss, &sslen);
if (incoming < 0) {
switch (errno) {
@@
-349,8
+353,10
@@
int main(int argc, char **argv)
usage(daemon_usage);
}
usage(daemon_usage);
}
- if (inetd_mode)
+ if (inetd_mode) {
+ fclose(stderr); //FIXME: workaround
return execute();
return execute();
+ }
return serve(port);
}
return serve(port);
}