index 12812c7132b20e35da6954757ddbcb5f6f2e7a7d..69c71edbd3e6f7ac9e5876841d9237f738267ab5 100644 (file)
sdb_log(SDB_LOG_DEBUG, "frontend: Closing connection on fd=%i",
conn->fd);
- close(conn->fd);
+ if (conn->fd >= 0)
+ close(conn->fd);
conn->fd = -1;
sdb_strbuf_destroy(conn->buf);
{
ssize_t n = 0;
+ if ((! conn) || (conn->fd < 0))
+ return -1;
+
while (42) {
ssize_t status;
if (status < 0) {
if ((errno == EAGAIN) || (errno == EWOULDBLOCK))
break;
+
+ close(conn->fd);
+ conn->fd = -1;
return (int)status;
}
else if (! status) /* EOF */
if (status < 0) {
char errbuf[1024];
+ /* tell other code that there was a problem and, more importantly,
+ * make sure we don't try to send further logs to the connection */
+ close(conn->fd);
+ conn->fd = -1;
+
sdb_log(SDB_LOG_ERR, "frontend: Failed to send msg "
"(code: %u, len: %u) to client: %s", code, msg_len,
sdb_strerror(errno, errbuf, sizeof(errbuf)));