diff -r 8ac56edb4e94 -r 3da1f7b6847f src/server/safs/service.c --- a/src/server/safs/service.c Tue Jan 01 14:02:25 2013 +0100 +++ b/src/server/safs/service.c Tue Jan 01 19:22:56 2013 +0100 @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright 2011 Olaf Wintermann. All rights reserved. + * Copyright 2013 Olaf Wintermann. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -27,7 +27,6 @@ */ #include -#include #include #include @@ -39,6 +38,8 @@ #include #include "../util/strbuf.h" +#include + // TODO: system sendfile Abstraktionen in neue Datei auslagern /* ssize_t sys_sendfile(int out_fd, int in_fd, off_t *off, size_t len) { @@ -53,7 +54,7 @@ * * adds content-length header and starts the response * - * return the file descriptor or an error code + * return the file descriptor or -1 */ int prepare_service_file(Session *sn, Request *rq) { char *ppath = pblock_findkeyval(pb_key_ppath, rq->vars); @@ -64,7 +65,8 @@ perror("prepare_service_file: open"); int status = 500; - switch(errno) { + int en = errno; + switch(en) { case EACCES: { status = 403; break; @@ -103,9 +105,9 @@ int send_file(pblock *pb, Session *sn, Request *rq) { int fd = prepare_service_file(sn, rq); if(fd < 0) { - /* TODO: service error */ - http_start_response(sn, rq); - return REQ_PROCEED; + // if an error occurs, prepare_service_file sets the http status code + // we can just return REQ_ABORTED + return REQ_ABORTED; } /* send file*/