read.c
800 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
static
int
serverRead(Server this)
{
unsigned int i;
for (i=1; i<this->nfds; i++) {
if (0 != ((this->fds)[i].revents & POLLIN)) {
if (NULL == (this->conns)[i].reader) {
loggerLog(
this->logger,
LOGGER_INFO,
"initialization error: NULL reader");
serverCloseConn(this, i);
}
switch (streamReaderRead((this->conns)[i].reader, (this->fds)[i].fd)) {
case 0:
/*
* normal close: write remaining data
* @TODO: actually we have no remaining data here....
*/
/* DROP-THROUGH */
case -1:
/*
* read failure / close connection
*/
loggerLog(this->logger, LOGGER_INFO, "connection closed...");
serverCloseConn(this, i);
break;
default:
break;
}
}
}
return 0;
}
// vim: set ts=4 sw=4: