*
*/
-#ifdef HAVE_LINUX_SENDFILE
-#include <sys/sendfile.h>
-#endif
#include "cgit.h"
#include "cache.h"
#include "html.h"
+#ifdef HAVE_LINUX_SENDFILE
+#include <sys/sendfile.h>
+#endif
#define CACHE_BUFSIZE (1024 * 4)
return errno;
/* Redirect stdout to lockfile */
- if (dup2(slot->lock_fd, STDOUT_FILENO) == -1)
+ if (dup2(slot->lock_fd, STDOUT_FILENO) == -1) {
+ close(tmp);
return errno;
+ }
/* Generate cache content */
slot->fn();
/* update stat info */
- if (fstat(slot->lock_fd, &slot->cache_st))
+ if (fstat(slot->lock_fd, &slot->cache_st)) {
+ close(tmp);
return errno;
+ }
/* Restore stdout */
- if (dup2(tmp, STDOUT_FILENO) == -1)
+ if (dup2(tmp, STDOUT_FILENO) == -1) {
+ close(tmp);
return errno;
+ }
/* Close the temporary filedescriptor */
if (close(tmp))