subtree(3p/cgit): merge cgit-pink into depot cgit
cgit-pink is a maintained fork of cgit that follows upstream git more closely and already contains a lot of patches we already had applied. Consequently, it seems sensible it becomes our future upstream, we may even be able to upstream some of our custom, less invasive patches. Change-Id: Ia081e4508866f32298986c7160f4890c8a7c8922
This commit is contained in:
commit
40803d9c6d
39 changed files with 185 additions and 1616 deletions
52
third_party/cgit/cache.c
vendored
52
third_party/cgit/cache.c
vendored
|
|
@ -85,40 +85,45 @@ static int close_slot(struct cache_slot *slot)
|
|||
/* Print the content of the active cache slot (but skip the key). */
|
||||
static int print_slot(struct cache_slot *slot)
|
||||
{
|
||||
off_t off;
|
||||
#ifdef HAVE_LINUX_SENDFILE
|
||||
off_t start_off;
|
||||
int ret;
|
||||
off_t size;
|
||||
#endif
|
||||
|
||||
start_off = slot->keylen + 1;
|
||||
off = slot->keylen + 1;
|
||||
|
||||
#ifdef HAVE_LINUX_SENDFILE
|
||||
size = slot->cache_st.st_size;
|
||||
|
||||
do {
|
||||
ret = sendfile(STDOUT_FILENO, slot->cache_fd, &start_off,
|
||||
slot->cache_st.st_size - start_off);
|
||||
ssize_t ret;
|
||||
ret = sendfile(STDOUT_FILENO, slot->cache_fd, &off, size - off);
|
||||
if (ret < 0) {
|
||||
if (errno == EAGAIN || errno == EINTR)
|
||||
continue;
|
||||
/* Fall back to read/write on EINVAL or ENOSYS */
|
||||
if (errno == EINVAL || errno == ENOSYS)
|
||||
break;
|
||||
return errno;
|
||||
}
|
||||
return 0;
|
||||
if (off == size)
|
||||
return 0;
|
||||
} while (1);
|
||||
#else
|
||||
ssize_t i, j;
|
||||
#endif
|
||||
|
||||
i = lseek(slot->cache_fd, slot->keylen + 1, SEEK_SET);
|
||||
if (i != slot->keylen + 1)
|
||||
if (lseek(slot->cache_fd, off, SEEK_SET) != off)
|
||||
return errno;
|
||||
|
||||
do {
|
||||
i = j = xread(slot->cache_fd, slot->buf, sizeof(slot->buf));
|
||||
if (i > 0)
|
||||
j = xwrite(STDOUT_FILENO, slot->buf, i);
|
||||
} while (i > 0 && j == i);
|
||||
|
||||
if (i < 0 || j != i)
|
||||
return errno;
|
||||
else
|
||||
return 0;
|
||||
#endif
|
||||
ssize_t ret;
|
||||
ret = xread(slot->cache_fd, slot->buf, sizeof(slot->buf));
|
||||
if (ret < 0)
|
||||
return errno;
|
||||
if (ret == 0)
|
||||
return 0;
|
||||
if (write_in_full(STDOUT_FILENO, slot->buf, ret) < 0)
|
||||
return errno;
|
||||
} while (1);
|
||||
}
|
||||
|
||||
/* Check if the slot has expired */
|
||||
|
|
@ -265,6 +270,13 @@ static int process_slot(struct cache_slot *slot)
|
|||
{
|
||||
int err;
|
||||
|
||||
/*
|
||||
* Make sure any buffered data is flushed before we redirect,
|
||||
* do sendfile(2) or write(2)
|
||||
*/
|
||||
if (fflush(stdout))
|
||||
return errno;
|
||||
|
||||
err = open_slot(slot);
|
||||
if (!err && slot->match) {
|
||||
if (is_expired(slot)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue