Fixed closing of stream on transfer.

This commit is contained in:
Michael Jumper
2010-09-23 09:54:17 +00:00
parent 520d4cb789
commit 7bbc9b5ae5
3 changed files with 8 additions and 1 deletions

View File

@@ -49,6 +49,7 @@ ssize_t guac_flush_base64(GUACIO* io);
ssize_t guac_flush(GUACIO* io); ssize_t guac_flush(GUACIO* io);
int guac_select(GUACIO* io, int usec_timeout); int guac_select(GUACIO* io, int usec_timeout);
void guac_close(GUACIO* io); void guac_close(GUACIO* io);
void guac_close_final(GUACIO* io);
#endif #endif

View File

@@ -197,7 +197,7 @@ void guac_start_client(guac_client* client) {
/* Accept changes to client I/O only before handling messages */ /* Accept changes to client I/O only before handling messages */
if (client_copy.io != client->io) { if (client_copy.io != client->io) {
guac_close(client_copy.io); /* Close old I/O */ guac_close_final(client_copy.io); /* Close old I/O and fd */
client_copy.io = client->io; client_copy.io = client->io;
} }

View File

@@ -60,6 +60,12 @@ void guac_close(GUACIO* io) {
free(io); free(io);
} }
void guac_close_final(GUACIO* io) {
guac_flush(io);
close(io->fd);
free(io);
}
/* Write bytes, limit rate */ /* Write bytes, limit rate */
ssize_t __guac_write(GUACIO* io, const char* buf, int count) { ssize_t __guac_write(GUACIO* io, const char* buf, int count) {