summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2014-07-12 23:13:13 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2014-07-12 23:17:38 +0200
commitccb2e4006d5b890cbcf1d32e255b689192d43240 (patch)
treeb136b1a045a5287bec2863f75e9f60c75ac48cff
parent5ad2781681d26b2923e9f432db0e981fa7b7da72 (diff)
downloadxK-ccb2e4006d5b890cbcf1d32e255b689192d43240.tar.gz
xK-ccb2e4006d5b890cbcf1d32e255b689192d43240.tar.xz
xK-ccb2e4006d5b890cbcf1d32e255b689192d43240.zip
Implement irc_try_write()
-rw-r--r--src/kike.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/kike.c b/src/kike.c
index 92d0f93..7c151e4 100644
--- a/src/kike.c
+++ b/src/kike.c
@@ -456,7 +456,27 @@ irc_try_read_ssl (struct connection *conn)
static bool
irc_try_write (struct connection *conn)
{
- // TODO
+ struct str *buf = &conn->write_buffer;
+ ssize_t n_written;
+
+ while (buf->len)
+ {
+ n_written = send (conn->socket_fd, buf->str, buf->len, 0);
+ if (n_written >= 0)
+ {
+ str_remove_slice (buf, 0, n_written);
+ continue;
+ }
+
+ if (errno == EAGAIN)
+ return true;
+ if (errno == EINTR)
+ continue;
+
+ print_debug ("%s: %s: %s", __func__, "send", strerror (errno));
+ connection_kill (conn, strerror (errno));
+ return false;
+ }
return true;
}