Skip to content

Commit

Permalink
only use sendfile on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
droundy committed Feb 28, 2015
1 parent 37c3738 commit 48dc5f8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -12,7 +12,7 @@ targets.o : lib/iterablehash.h lib/listset.h lib/sha1.h fac.h targets.c
clean.o : lib/iterablehash.h lib/listset.h lib/sha1.h fac.h clean.c
gcc -std=c11 -c clean.c

new-build.o : lib/hashset.h environ.h lib/listset.h lib/bigbrother.h lib/sha1.h lib/iterablehash.h fac.h new-build.c new-build.h
new-build.o : lib/hashset.h environ.h lib/iterablehash.h lib/listset.h lib/bigbrother.h lib/sha1.h fac.h new-build.c new-build.h
gcc -std=c11 -c new-build.c

git.o : lib/iterablehash.h lib/listset.h lib/sha1.h fac.h git.c
Expand Down
6 changes: 6 additions & 0 deletions new-build.c
Expand Up @@ -11,7 +11,11 @@
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/time.h>

#ifdef __linux__
#include <sys/sendfile.h>
#endif

#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
Expand Down Expand Up @@ -516,7 +520,9 @@ static void build_marked(struct all_targets *all, const char *log_directory) {
if (bs[i]->all_done != built || show_output) {
off_t stdoutlen = lseek(bs[i]->stdouterrfd, 0, SEEK_END);
off_t myoffset = 0;
#ifdef __linux__
sendfile(1, bs[i]->stdouterrfd, &myoffset, stdoutlen);
#endif
}
if (bs[i]->all_done != built && bs[i]->all_done != failed) {
printf("INTERRUPTED! bs[i]->all_done == %s\n",
Expand Down

0 comments on commit 48dc5f8

Please sign in to comment.