summaryrefslogtreecommitdiff
path: root/src/irc
diff options
context:
space:
mode:
authorailin-nemui <ailin-nemui@users.noreply.github.com>2016-11-23 16:23:35 +0100
committerailin-nemui <ailin-nemui@users.noreply.github.com>2016-11-23 17:02:29 +0100
commitdcffa98d4629ee1810900d0dde1234050e68d39e (patch)
tree0874bc9c26f3430f86f78b7a9619174812b141ee /src/irc
parent1aff5c2c97b452ffdb5c59cf62f29048731b9f40 (diff)
downloadirssi-dcffa98d4629ee1810900d0dde1234050e68d39e.zip
add a static buffer for dcc received data
increased buffersize might make irssi freeze less / #159
Diffstat (limited to 'src/irc')
-rw-r--r--src/irc/dcc/dcc-get.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/irc/dcc/dcc-get.c b/src/irc/dcc/dcc-get.c
index f7a95bb9..73c1b864 100644
--- a/src/irc/dcc/dcc-get.c
+++ b/src/irc/dcc/dcc-get.c
@@ -30,6 +30,8 @@
#include "dcc-get.h"
#include "dcc-send.h"
+static char *dcc_get_recv_buffer;
+
GET_DCC_REC *dcc_get_create(IRC_SERVER_REC *server, CHAT_DCC_REC *chat,
const char *nick, const char *arg)
{
@@ -139,14 +141,20 @@ static void sig_dccget_send(GET_DCC_REC *dcc)
dcc_get_send_received(dcc);
}
+#define DCC_GET_RECV_BUFFER_SIZE 32768
+
/* input function: DCC GET received data */
static void sig_dccget_receive(GET_DCC_REC *dcc)
{
- char buffer[512];
int ret;
+ if (dcc_get_recv_buffer == NULL) {
+ dcc_get_recv_buffer = g_malloc(DCC_GET_RECV_BUFFER_SIZE);
+ }
+
for (;;) {
- ret = net_receive(dcc->handle, buffer, sizeof(buffer));
+ ret = net_receive(dcc->handle, dcc_get_recv_buffer,
+ DCC_GET_RECV_BUFFER_SIZE);
if (ret == 0) break;
if (ret < 0) {
@@ -156,7 +164,7 @@ static void sig_dccget_receive(GET_DCC_REC *dcc)
return;
}
- if (write(dcc->fhandle, buffer, ret) != ret) {
+ if (write(dcc->fhandle, dcc_get_recv_buffer, ret) != ret) {
/* most probably out of disk space */
signal_emit("dcc error write", 2,
dcc, g_strerror(errno));
@@ -596,4 +604,5 @@ void dcc_get_deinit(void)
signal_remove("dcc destroyed", (SIGNAL_FUNC) sig_dcc_destroyed);
signal_remove("ctcp msg dcc send", (SIGNAL_FUNC) ctcp_msg_dcc_send);
command_unbind("dcc get", (SIGNAL_FUNC) cmd_dcc_get);
+ g_free_and_null(dcc_get_recv_buffer);
}