Server 0.0.1
HTTP/REST server implementation

src/server/read.c

Go to the documentation of this file.
00001 
00023 #include "server.h"
00024 #include "logger.h"
00025 #include "stream.h"
00026 
00027 void    serverCloseConn(Server, unsigned int);
00028 
00029 ssize_t
00030 serverRead(Server this, unsigned int i)
00031 {
00032         int     fd = (this->fds)[i].fd;
00033         ssize_t size;
00034 
00035         if (NULL == (this->conns)[fd].worker) {
00036                 loggerLog(
00037                                 this->logger,
00038                                 LOGGER_INFO,
00039                                 "initialization error: NULL reader");
00040                 return -1;
00041         }
00042 
00043         switch ((size = streamReaderRead(
00044                                         (this->conns)[fd].worker,
00045                                         (this->conns)[fd].stream)))
00046         {
00047                 case -2:
00055                         // DROP-THROUGH
00056 
00057                 case -1: 
00058                         /*
00059                          * read failure / close connection
00060                          */
00061                         loggerLog(this->logger, LOGGER_INFO,
00062                                         "connection[%d] closed...%s",
00063                                         fd,
00064                                         inet_ntoa((((this->conns)[fd].sock)->addr).sin_addr));
00065                         serverCloseConn(this, i);
00066                         break;
00067 
00068                 case 0:
00069                         break;
00070 
00071                 default:
00072                         (this->fds)[i].events |= POLLOUT;
00073                         break;
00074         }
00075 
00076         return size;
00077 }
00078 
00079 // vim: set ts=4 sw=4:
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines