diff --git a/ChangeLog b/ChangeLog index 3be050d..9a79ba3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,10 +1,14 @@ +2012-02-20 17:16:44 +0100 Georg Hopp + + * changed /**/ single line comments to // (HEAD, master) + 2012-02-20 14:55:46 +0100 Georg Hopp - * start documenting this whole stuff...well at least add a copyright information in each file (HEAD, master) + * start documenting this whole stuff...well at least add a copyright information in each file (origin/master, origin/HEAD) 2012-02-20 10:10:29 +0100 Georg Hopp - * first very crude, not complete, experimental 304 test implementation (origin/master, origin/HEAD) + * first very crude, not complete, experimental 304 test implementation 2012-02-20 07:55:06 +0100 Georg Hopp diff --git a/include/http/message/queue.h b/include/http/message/queue.h index dac7f32..b4d6052 100644 --- a/include/http/message/queue.h +++ b/include/http/message/queue.h @@ -37,6 +37,6 @@ CLASS(HttpMessageQueue) { size_t nmsgs; }; -#endif /* __HTTP_MESSAGE_QUEUE_H__ */ +#endif // __HTTP_MESSAGE_QUEUE_H__ // vim: set ts=4 sw=4: diff --git a/include/http/request.h b/include/http/request.h index e97fec2..ba1f979 100644 --- a/include/http/request.h +++ b/include/http/request.h @@ -40,6 +40,6 @@ CLASS(HttpRequest) { int httpRequestHasValidMethod(HttpRequest); -#endif /* __HTTP_REQUEST_H__ */ +#endif // __HTTP_REQUEST_H__ // vim: set ts=4 sw=4: diff --git a/include/http/request/parser.h b/include/http/request/parser.h index 9ada378..165bf9f 100644 --- a/include/http/request/parser.h +++ b/include/http/request/parser.h @@ -67,6 +67,6 @@ ssize_t httpRequestParserGetRequestLine(HttpRequestParser, char *); ssize_t httpRequestParserGetHeader(HttpRequestParser, char *); void httpRequestParserGetBody(HttpRequestParser); -#endif /* __HTTP_REQUEST_PARSER_H__ */ +#endif // __HTTP_REQUEST_PARSER_H__ // vim: set ts=4 sw=4: diff --git a/include/http/response.h b/include/http/response.h index a9e1c57..2b263d9 100644 --- a/include/http/response.h +++ b/include/http/response.h @@ -43,6 +43,6 @@ HttpResponse httpResponse404(); HttpResponse httpResponseMe(); HttpResponse httpResponseImage(int); -#endif /* __HTTP_RESPONSE_H__ */ +#endif // __HTTP_RESPONSE_H__ // vim: set ts=4 sw=4: diff --git a/src/daemonize.c b/src/daemonize.c index 80c6585..6d77a08 100644 --- a/src/daemonize.c +++ b/src/daemonize.c @@ -37,10 +37,10 @@ void daemonize(void) { exit(EXIT_SUCCESS); } - /* make new child session leader */ + // make new child session leader setsid(); - /* connect all standard streams to /dev/null */ + // connect all standard streams to /dev/null stderr = freopen("/dev/null", "w", stderr); stdin = freopen("/dev/null", "r", stdin); stdout = freopen("/dev/null", "w", stdout); diff --git a/src/http/request/parser/parse.c b/src/http/request/parser/parse.c index 0718b3b..78481f0 100644 --- a/src/http/request/parser/parse.c +++ b/src/http/request/parser/parse.c @@ -48,23 +48,6 @@ httpRequestParserParse(HttpRequestParser this, int fd) } if (NULL != this->incomplete) { - /** - * i need a way to stop incomplete requests - * from locking the buffer forever. - * Maybe this is the position for this... - * but i must carefully think about the - * conditions...maybe a rewrite of the - * parser is neccessary to detect a - * stale request. - * The problem here seems to be that i can't - * say for sure if the request is stale. - * This is mostly because i work linewise. - * This MUST be accomplished within - * request line and header reads. - * As far as i see the only way it to - * always empty the buffer completely after - * every read and release the buffer then. - */ cbufSetData(this->buffer, this->incomplete, this->isize); free(this->incomplete); this->incomplete = NULL; diff --git a/src/http/response/writer/write.c b/src/http/response/writer/write.c index 516a817..7aec1bb 100644 --- a/src/http/response/writer/write.c +++ b/src/http/response/writer/write.c @@ -143,7 +143,7 @@ httpResponseWriterWrite(HttpResponseWriter this, int fd) /** * if the message did not have the keep-alive feature * we don't care about further pipelined messages and - * return to the caller with a 0 indicating that the + * return to the caller with a -1 indicating that the * underlying connection should be closed. */ cbufRelease(this->buffer); diff --git a/src/server/handle_accept.c b/src/server/handle_accept.c index 8fc91b8..74de04d 100644 --- a/src/server/handle_accept.c +++ b/src/server/handle_accept.c @@ -39,10 +39,10 @@ serverHandleAccept(Server this) acc = socketAccept(this->sock, &remoteAddr); if (-1 != acc->handle) { - //* save the socket handle + // save the socket handle (this->conns)[acc->handle].sock = acc; - //* clone worker + // clone worker (this->conns)[acc->handle].worker = clone(this->worker); /** diff --git a/src/server/poll.c b/src/server/poll.c index bb1d352..2dd5600 100644 --- a/src/server/poll.c +++ b/src/server/poll.c @@ -26,26 +26,6 @@ #define POLLFD(ptr) ((struct pollfd *)(ptr)) #define SWAP(a, b) ((a)^=(b),(b)^=(a),(a)^=(b)) -static -inline -int -sortEvents(const void * a, const void * b) -{ - return POLLFD(a)->events > POLLFD(b)->events ? - -1 : POLLFD(a)->events < POLLFD(b)->events ? - 1 : 0; -} - -static -inline -int -sortRevents(const void * a, const void * b) -{ - return POLLFD(a)->revents > POLLFD(b)->revents ? - -1 : POLLFD(a)->revents < POLLFD(b)->revents ? - 1 : 0; -} - static int serverPoll(Server this) { diff --git a/src/server/run.c b/src/server/run.c index 363360c..d2c64e5 100644 --- a/src/server/run.c +++ b/src/server/run.c @@ -51,7 +51,7 @@ serverRun(Server this) * What we can first do to get some processing between read/write * cicles is to use the poll timeout. */ - while (!doShutdown) /* until error or signal */ + while (!doShutdown) //! until error or signal { int events; unsigned int i; diff --git a/src/signalHandling.c b/src/signalHandling.c index 3fdc3f9..4771fa0 100644 --- a/src/signalHandling.c +++ b/src/signalHandling.c @@ -20,7 +20,7 @@ * along with this program. If not, see . */ -#include /* for signal() and signal names */ +#include // for signal() and signal names volatile int doShutdown; diff --git a/src/socket.c b/src/socket.c index 819a0b9..c52750a 100644 --- a/src/socket.c +++ b/src/socket.c @@ -34,27 +34,20 @@ void ctor(void * _this, va_list * params) { Sock this = _this; - int reUse = 1; /* TODO: make this configurable */ + int reUse = 1; //! \todo make this configurable this->log = va_arg(* params, Logger); this->port = va_arg(* params, int); - /* Create socket for incoming connections */ + //! Create socket for incoming connections if (-1 == (this->handle = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP))) { loggerLog(this->log, LOGGER_CRIT, "error opening socket: %s - service terminated", strerror(errno)); - //exit(EXIT_FAILURE); - /** - * \todo uhhhh, here we are leaking memory the socket is not - * initialized correctly and no one notices... - * Think about a way to prevent this. - * Well maybe we notice in server.... - */ return; } - /* Make the socket REUSE a TIME_WAIT socket */ + //! Make the socket REUSE a TIME_WAIT socket setsockopt(this->handle, SOL_SOCKET, SO_REUSEADDR, &reUse, sizeof (reUse)); } diff --git a/src/socket/accept.c b/src/socket/accept.c index 1d95039..f0d63ae 100644 --- a/src/socket/accept.c +++ b/src/socket/accept.c @@ -20,7 +20,7 @@ * along with this program. If not, see . */ -#include /* for errno */ +#include // for errno #include #include "socket.h" @@ -30,10 +30,10 @@ Sock socketAccept(Sock this, char (*remoteAddr)[16]) { - Sock sock; /* Socket for client */ - unsigned int len; /* Length of client address data structure */ + Sock sock; // Socket for client + unsigned int len; // Length of client address data structure - /* Set the size of the in-out parameter */ + // Set the size of the in-out parameter len = sizeof(this->addr); /** @@ -49,7 +49,7 @@ socketAccept(Sock this, char (*remoteAddr)[16]) * \todo change port to remote port on success */ - /* Wait for a client to connect */ + // Wait for a client to connect sock->handle = accept(this->handle, (struct sockaddr *) &(sock->addr), &len); if (-1 == sock->handle) { loggerLog(this->log, LOGGER_WARNING, diff --git a/src/socket/connect.c b/src/socket/connect.c index 2f653ee..fe5870d 100644 --- a/src/socket/connect.c +++ b/src/socket/connect.c @@ -20,8 +20,8 @@ * along with this program. If not, see . */ -#include /* for atoi() and exit() */ -#include /* for errno */ +#include // for atoi() and exit() +#include // for errno #include "socket.h" #include "interface/class.h" @@ -32,8 +32,8 @@ void socketConnect(Sock this, const char * addr) { inet_pton(AF_INET, addr, &((this->addr).sin_addr)); - (this->addr).sin_family = AF_INET; /* Internet address family */ - (this->addr).sin_port = htons(this->port); /* Local port */ + (this->addr).sin_family = AF_INET; // Internet address family + (this->addr).sin_port = htons(this->port); // Local port if (-1 == connect(this->handle, (struct sockaddr*) &(this->addr), sizeof(this->addr))) { loggerLog(this->log, LOGGER_CRIT, diff --git a/src/socket/listen.c b/src/socket/listen.c index 3a557ae..4992058 100644 --- a/src/socket/listen.c +++ b/src/socket/listen.c @@ -20,8 +20,8 @@ * along with this program. If not, see . */ -#include /* for atoi() and exit() */ -#include /* for errno */ +#include // for atoi() and exit() +#include // for errno #include "socket.h" #include "interface/class.h" @@ -31,11 +31,13 @@ void socketListen(Sock this, int backlog) { - (this->addr).sin_family = AF_INET; /* Internet address family */ - (this->addr).sin_addr.s_addr = htonl(INADDR_ANY); /* Any incoming interface */ - (this->addr).sin_port = htons(this->port); /* Local port */ + (this->addr).sin_family = AF_INET; // Internet address family + (this->addr).sin_addr.s_addr = htonl(INADDR_ANY); // Any incoming interface + (this->addr).sin_port = htons(this->port); // Local port - /* Bind to the local address */ + /** + * Bind to the local address + */ if (-1 == bind(this->handle, (struct sockaddr *) &(this->addr), sizeof(this->addr))) { loggerLog(this->log, LOGGER_CRIT, "error binding socket: %s - service terminated", @@ -43,7 +45,9 @@ socketListen(Sock this, int backlog) exit(EXIT_FAILURE); } - /* Mark the socket so it will listen for incoming connections */ + /** + * Mark the socket so it will listen for incoming connections + */ if (-1 == listen(this->handle, backlog)) { loggerLog(this->log, LOGGER_CRIT, "error binding socket: %s - service terminated",