index 58a2cb4d3e3d06d510927b57b414f37bc3af425c..55843fd049d9e2569c24b8d42c6d20776039929d 100644 (file)
}
sdb_log(SDB_LOG_DEBUG, "frontend: Closing connection %s", obj->name);
- if (conn->fd >= 0)
- close(conn->fd);
- conn->fd = -1;
+ sdb_connection_close(conn);
if (conn->username)
free(conn->username);
/* reset */
sdb_strbuf_clear(conn->errbuf);
- conn->cmd = sdb_proto_get_int(conn->buf, 0);
- conn->cmd_len = sdb_proto_get_int(conn->buf, sizeof(uint32_t));
-
+ if (sdb_proto_unmarshal_header(conn->buf, &conn->cmd, &conn->cmd_len))
+ return -1;
sdb_strbuf_skip(conn->buf, 0, 2 * sizeof(uint32_t));
if ((! conn->ready) && (conn->cmd != SDB_CONNECTION_STARTUP))
if ((errno == EAGAIN) || (errno == EWOULDBLOCK))
break;
- close(conn->fd);
- conn->fd = -1;
+ sdb_connection_close(conn);
return (int)status;
}
else if (! status) /* EOF */
/* 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_connection_close(conn);
conn->ready = 0;
sdb_log(SDB_LOG_ERR, "frontend: Failed to send msg "