Flush any output buffers for this socket. */
| 2157 | |
| 2158 | /* Flush any output buffers for this socket. */ |
| 2159 | int SIPpSocket::flush() |
| 2160 | { |
| 2161 | struct socketbuf *buf; |
| 2162 | int ret; |
| 2163 | |
| 2164 | while ((buf = ss_out)) { |
| 2165 | ssize_t size = buf->len - buf->offset; |
| 2166 | ret = write_primitive(buf->buf + buf->offset, size, &buf->addr); |
| 2167 | TRACE_MSG("Wrote %d of %zu bytes in an output buffer.\n", ret, size); |
| 2168 | if (ret == size) { |
| 2169 | /* Everything is great, throw away this buffer. */ |
| 2170 | ss_out = buf->next; |
| 2171 | free_socketbuf(buf); |
| 2172 | } else if (ret <= 0) { |
| 2173 | /* Handle connection closes and errors. */ |
| 2174 | return write_error(ret); |
| 2175 | } else { |
| 2176 | /* We have written more of the partial buffer. */ |
| 2177 | buf->offset += ret; |
| 2178 | errno = EWOULDBLOCK; |
| 2179 | enter_congestion(EWOULDBLOCK); |
| 2180 | return -1; |
| 2181 | } |
| 2182 | } |
| 2183 | |
| 2184 | return 0; |
| 2185 | } |
| 2186 | |
| 2187 | /* Write data to a socket. */ |
| 2188 | int SIPpSocket::write(const char *buffer, ssize_t len, int flags, struct sockaddr_storage *dest) |
no test coverage detected