summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLemonBoy <LemonBoy@users.noreply.github.com>2016-11-25 21:52:30 +0100
committerGitHub <noreply@github.com>2016-11-25 21:52:30 +0100
commit1c0f048d2cc0184105f6e2fff835be7efa633a7b (patch)
tree0874bc9c26f3430f86f78b7a9619174812b141ee
parent1aff5c2c97b452ffdb5c59cf62f29048731b9f40 (diff)
parentdcffa98d4629ee1810900d0dde1234050e68d39e (diff)
downloadirssi-1c0f048d2cc0184105f6e2fff835be7efa633a7b.zip
Merge pull request #578 from ailin-nemui/dcc_buffer
add a static buffer for dcc received data
-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);
}