Commit 05a7a386fa7805658a0772129bd008ef5c4c9886

Authored by Georg Hopp
1 parent d2d1229e

fixed some warnings

1 1 #include <stdlib.h>
  2 +#include <stdio.h>
2 3 #include <stdarg.h>
3 4
4 5 #include "logger.h"
... ...
... ... @@ -129,12 +129,28 @@ serverRun(Server this)
129 129 * handle writes
130 130 */
131 131 if (0 != ((this->fds)[i].revents & POLLOUT)) {
132   - write(
  132 + int size;
  133 +
  134 + size = write(
133 135 (this->fds)[i].fd,
134 136 (this->conns)[fd].wbuf,
135 137 strlen((this->conns)[fd].wbuf));
136   - (this->fds)[i].events = (this->fds)[i].events & ~POLLOUT;
137   - serverCloseConn(this, i);
  138 +
  139 + if (size == strlen((this->conns)[fd].wbuf) ||
  140 + -1 == size) {
  141 + if (-1 == size) {
  142 + loggerLog(this->logger, LOGGER_ERR,
  143 + "write error, closing connection");
  144 + }
  145 +
  146 + (this->fds)[i].events = (this->fds)[i].events & ~POLLOUT;
  147 + serverCloseConn(this, i);
  148 + }
  149 + else {
  150 + memmove((this->conns)[fd].wbuf,
  151 + (this->conns)[fd].wbuf + size,
  152 + strlen((this->conns)[fd].wbuf) - size + 1);
  153 + }
138 154 }
139 155 }
140 156 }
... ...
1 1 #include <errno.h>
2 2 #include <stdlib.h>
  3 +#include <unistd.h>
3 4
4 5 #include "socket.h"
5 6 #include "logger.h"
... ...
1 1 #include <errno.h> /* for errno */
  2 +#include <unistd.h>
2 3
3 4 #include "socket.h"
4 5 #include "interface/class.h"
... ...
Please register or login to post a comment