diff options
author | Timo Sirainen <cras@irssi.org> | 2001-11-20 00:54:51 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2001-11-20 00:54:51 +0000 |
commit | 333f6a3bab94de48db1c66cd014d9b4b8f11381c (patch) | |
tree | 55cf3b9b8180969cff9ee759379d79b947f64c06 /src/core | |
parent | 04275a632ebbb816ff0e56b5dc92800a722c3013 (diff) | |
download | irssi-333f6a3bab94de48db1c66cd014d9b4b8f11381c.zip |
Added net_sendbuffer_flush() for flushing the buffer.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2112 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/net-sendbuffer.c | 21 | ||||
-rw-r--r-- | src/core/net-sendbuffer.h | 3 |
2 files changed, 23 insertions, 1 deletions
diff --git a/src/core/net-sendbuffer.c b/src/core/net-sendbuffer.c index 04eab80a..fd1039d6 100644 --- a/src/core/net-sendbuffer.c +++ b/src/core/net-sendbuffer.c @@ -62,7 +62,7 @@ void net_sendbuffer_destroy(NET_SENDBUF_REC *rec, int close) g_free(rec); } -/* Transmit all data from buffer - return TRUE if successful */ +/* Transmit all data from buffer - return TRUE if the whole buffer was sent */ static int buffer_send(NET_SENDBUF_REC *rec) { int ret; @@ -140,6 +140,25 @@ int net_sendbuffer_send(NET_SENDBUF_REC *rec, const void *data, int size) return buffer_add(rec, data, size) ? 0 : -1; } +/* Flush the buffer, blocks until finished. */ +void net_sendbuffer_flush(NET_SENDBUF_REC *rec) +{ + int handle; + + if (rec->buffer == NULL) + return; + + /* set the socket blocking while doing this */ + handle = g_io_channel_unix_get_fd(rec->handle); +#ifndef WIN32 + fcntl(handle, F_SETFL, 0); +#endif + while (!buffer_send(rec)) ; +#ifndef WIN32 + fcntl(handle, F_SETFL, O_NONBLOCK); +#endif +} + /* Returns the socket handle */ GIOChannel *net_sendbuffer_handle(NET_SENDBUF_REC *rec) { diff --git a/src/core/net-sendbuffer.h b/src/core/net-sendbuffer.h index bb6d8e07..d2388b41 100644 --- a/src/core/net-sendbuffer.h +++ b/src/core/net-sendbuffer.h @@ -14,6 +14,9 @@ void net_sendbuffer_destroy(NET_SENDBUF_REC *rec, int close); occured. */ int net_sendbuffer_send(NET_SENDBUF_REC *rec, const void *data, int size); +/* Flush the buffer, blocks until finished. */ +void net_sendbuffer_flush(NET_SENDBUF_REC *rec); + /* Returns the socket handle */ GIOChannel *net_sendbuffer_handle(NET_SENDBUF_REC *rec); |