mirror of
https://github.com/irssi/irssi.git
synced 2024-11-03 04:27:19 -05:00
Added net_sendbuffer_flush() for flushing the buffer.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2112 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
04275a632e
commit
333f6a3bab
@ -62,7 +62,7 @@ void net_sendbuffer_destroy(NET_SENDBUF_REC *rec, int close)
|
|||||||
g_free(rec);
|
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)
|
static int buffer_send(NET_SENDBUF_REC *rec)
|
||||||
{
|
{
|
||||||
int ret;
|
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;
|
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 */
|
/* Returns the socket handle */
|
||||||
GIOChannel *net_sendbuffer_handle(NET_SENDBUF_REC *rec)
|
GIOChannel *net_sendbuffer_handle(NET_SENDBUF_REC *rec)
|
||||||
{
|
{
|
||||||
|
@ -14,6 +14,9 @@ void net_sendbuffer_destroy(NET_SENDBUF_REC *rec, int close);
|
|||||||
occured. */
|
occured. */
|
||||||
int net_sendbuffer_send(NET_SENDBUF_REC *rec, const void *data, int size);
|
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 */
|
/* Returns the socket handle */
|
||||||
GIOChannel *net_sendbuffer_handle(NET_SENDBUF_REC *rec);
|
GIOChannel *net_sendbuffer_handle(NET_SENDBUF_REC *rec);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user