| 164 | } |
| 165 | |
| 166 | static int connSocketWrite(connection *conn, const void *data, size_t data_len) { |
| 167 | int ret = write(conn->fd, data, data_len); |
| 168 | if (ret < 0 && errno != EAGAIN) { |
| 169 | conn->last_errno = errno; |
| 170 | |
| 171 | /* Don't overwrite the state of a connection that is not already |
| 172 | * connected, not to mess with handler callbacks. |
| 173 | */ |
| 174 | if (conn->state == CONN_STATE_CONNECTED) |
| 175 | conn->state = CONN_STATE_ERROR; |
| 176 | } |
| 177 | |
| 178 | return ret; |
| 179 | } |
| 180 | |
| 181 | static int connSocketRead(connection *conn, void *buf, size_t buf_len) { |
| 182 | int ret = read(conn->fd, buf, buf_len); |