Browse Source

changed /**/ single line comments to //

master
Georg Hopp 14 years ago
parent
commit
063189e664
  1. 8
      ChangeLog
  2. 2
      include/http/message/queue.h
  3. 2
      include/http/request.h
  4. 2
      include/http/request/parser.h
  5. 2
      include/http/response.h
  6. 4
      src/daemonize.c
  7. 17
      src/http/request/parser/parse.c
  8. 2
      src/http/response/writer/write.c
  9. 4
      src/server/handle_accept.c
  10. 20
      src/server/poll.c
  11. 2
      src/server/run.c
  12. 2
      src/signalHandling.c
  13. 13
      src/socket.c
  14. 10
      src/socket/accept.c
  15. 8
      src/socket/connect.c
  16. 18
      src/socket/listen.c

8
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 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 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 2012-02-20 07:55:06 +0100 Georg Hopp

2
include/http/message/queue.h

@ -37,6 +37,6 @@ CLASS(HttpMessageQueue) {
size_t nmsgs; size_t nmsgs;
}; };
#endif /* __HTTP_MESSAGE_QUEUE_H__ */
#endif // __HTTP_MESSAGE_QUEUE_H__
// vim: set ts=4 sw=4: // vim: set ts=4 sw=4:

2
include/http/request.h

@ -40,6 +40,6 @@ CLASS(HttpRequest) {
int httpRequestHasValidMethod(HttpRequest); int httpRequestHasValidMethod(HttpRequest);
#endif /* __HTTP_REQUEST_H__ */
#endif // __HTTP_REQUEST_H__
// vim: set ts=4 sw=4: // vim: set ts=4 sw=4:

2
include/http/request/parser.h

@ -67,6 +67,6 @@ ssize_t httpRequestParserGetRequestLine(HttpRequestParser, char *);
ssize_t httpRequestParserGetHeader(HttpRequestParser, char *); ssize_t httpRequestParserGetHeader(HttpRequestParser, char *);
void httpRequestParserGetBody(HttpRequestParser); void httpRequestParserGetBody(HttpRequestParser);
#endif /* __HTTP_REQUEST_PARSER_H__ */
#endif // __HTTP_REQUEST_PARSER_H__
// vim: set ts=4 sw=4: // vim: set ts=4 sw=4:

2
include/http/response.h

@ -43,6 +43,6 @@ HttpResponse httpResponse404();
HttpResponse httpResponseMe(); HttpResponse httpResponseMe();
HttpResponse httpResponseImage(int); HttpResponse httpResponseImage(int);
#endif /* __HTTP_RESPONSE_H__ */
#endif // __HTTP_RESPONSE_H__
// vim: set ts=4 sw=4: // vim: set ts=4 sw=4:

4
src/daemonize.c

@ -37,10 +37,10 @@ void daemonize(void) {
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
/* make new child session leader */
// make new child session leader
setsid(); setsid();
/* connect all standard streams to /dev/null */
// connect all standard streams to /dev/null
stderr = freopen("/dev/null", "w", stderr); stderr = freopen("/dev/null", "w", stderr);
stdin = freopen("/dev/null", "r", stdin); stdin = freopen("/dev/null", "r", stdin);
stdout = freopen("/dev/null", "w", stdout); stdout = freopen("/dev/null", "w", stdout);

17
src/http/request/parser/parse.c

@ -48,23 +48,6 @@ httpRequestParserParse(HttpRequestParser this, int fd)
} }
if (NULL != this->incomplete) { 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); cbufSetData(this->buffer, this->incomplete, this->isize);
free(this->incomplete); free(this->incomplete);
this->incomplete = NULL; this->incomplete = NULL;

2
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 * if the message did not have the keep-alive feature
* we don't care about further pipelined messages and * 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. * underlying connection should be closed.
*/ */
cbufRelease(this->buffer); cbufRelease(this->buffer);

4
src/server/handle_accept.c

@ -39,10 +39,10 @@ serverHandleAccept(Server this)
acc = socketAccept(this->sock, &remoteAddr); acc = socketAccept(this->sock, &remoteAddr);
if (-1 != acc->handle) { if (-1 != acc->handle) {
//* save the socket handle
// save the socket handle
(this->conns)[acc->handle].sock = acc; (this->conns)[acc->handle].sock = acc;
//* clone worker
// clone worker
(this->conns)[acc->handle].worker = clone(this->worker); (this->conns)[acc->handle].worker = clone(this->worker);
/** /**

20
src/server/poll.c

@ -26,26 +26,6 @@
#define POLLFD(ptr) ((struct pollfd *)(ptr)) #define POLLFD(ptr) ((struct pollfd *)(ptr))
#define SWAP(a, b) ((a)^=(b),(b)^=(a),(a)^=(b)) #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 static
int int
serverPoll(Server this) { serverPoll(Server this) {

2
src/server/run.c

@ -51,7 +51,7 @@ serverRun(Server this)
* What we can first do to get some processing between read/write * What we can first do to get some processing between read/write
* cicles is to use the poll timeout. * cicles is to use the poll timeout.
*/ */
while (!doShutdown) /* until error or signal */
while (!doShutdown) //! until error or signal
{ {
int events; int events;
unsigned int i; unsigned int i;

2
src/signalHandling.c

@ -20,7 +20,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <signal.h> /* for signal() and signal names */
#include <signal.h> // for signal() and signal names
volatile int doShutdown; volatile int doShutdown;

13
src/socket.c

@ -34,27 +34,20 @@ void
ctor(void * _this, va_list * params) ctor(void * _this, va_list * params)
{ {
Sock this = _this; Sock this = _this;
int reUse = 1; /* TODO: make this configurable */
int reUse = 1; //! \todo make this configurable
this->log = va_arg(* params, Logger); this->log = va_arg(* params, Logger);
this->port = va_arg(* params, int); 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))) { if (-1 == (this->handle = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP))) {
loggerLog(this->log, LOGGER_CRIT, loggerLog(this->log, LOGGER_CRIT,
"error opening socket: %s - service terminated", "error opening socket: %s - service terminated",
strerror(errno)); 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; 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)); setsockopt(this->handle, SOL_SOCKET, SO_REUSEADDR, &reUse, sizeof (reUse));
} }

10
src/socket/accept.c

@ -20,7 +20,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <errno.h> /* for errno */
#include <errno.h> // for errno
#include <unistd.h> #include <unistd.h>
#include "socket.h" #include "socket.h"
@ -30,10 +30,10 @@
Sock Sock
socketAccept(Sock this, char (*remoteAddr)[16]) 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); len = sizeof(this->addr);
/** /**
@ -49,7 +49,7 @@ socketAccept(Sock this, char (*remoteAddr)[16])
* \todo change port to remote port on success * \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); sock->handle = accept(this->handle, (struct sockaddr *) &(sock->addr), &len);
if (-1 == sock->handle) { if (-1 == sock->handle) {
loggerLog(this->log, LOGGER_WARNING, loggerLog(this->log, LOGGER_WARNING,

8
src/socket/connect.c

@ -20,8 +20,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <stdlib.h> /* for atoi() and exit() */
#include <errno.h> /* for errno */
#include <stdlib.h> // for atoi() and exit()
#include <errno.h> // for errno
#include "socket.h" #include "socket.h"
#include "interface/class.h" #include "interface/class.h"
@ -32,8 +32,8 @@ void
socketConnect(Sock this, const char * addr) socketConnect(Sock this, const char * addr)
{ {
inet_pton(AF_INET, addr, &((this->addr).sin_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))) { if (-1 == connect(this->handle, (struct sockaddr*) &(this->addr), sizeof(this->addr))) {
loggerLog(this->log, LOGGER_CRIT, loggerLog(this->log, LOGGER_CRIT,

18
src/socket/listen.c

@ -20,8 +20,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <stdlib.h> /* for atoi() and exit() */
#include <errno.h> /* for errno */
#include <stdlib.h> // for atoi() and exit()
#include <errno.h> // for errno
#include "socket.h" #include "socket.h"
#include "interface/class.h" #include "interface/class.h"
@ -31,11 +31,13 @@
void void
socketListen(Sock this, int backlog) 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))) { if (-1 == bind(this->handle, (struct sockaddr *) &(this->addr), sizeof(this->addr))) {
loggerLog(this->log, LOGGER_CRIT, loggerLog(this->log, LOGGER_CRIT,
"error binding socket: %s - service terminated", "error binding socket: %s - service terminated",
@ -43,7 +45,9 @@ socketListen(Sock this, int backlog)
exit(EXIT_FAILURE); 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)) { if (-1 == listen(this->handle, backlog)) {
loggerLog(this->log, LOGGER_CRIT, loggerLog(this->log, LOGGER_CRIT,
"error binding socket: %s - service terminated", "error binding socket: %s - service terminated",

Loading…
Cancel
Save