diff options
Diffstat (limited to 'sql/sql_repl.cc')
-rw-r--r-- | sql/sql_repl.cc | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 963fde93f2d..e0f98b9e0bd 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -32,7 +32,7 @@ static int send_file(THD *thd) NET* net = &thd->net; int fd = -1,bytes, error = 1; char fname[FN_REFLEN+1]; - char buf[IO_SIZE*15]; + char *buf; const char *errmsg = 0; int old_timeout; DBUG_ENTER("send_file"); @@ -42,6 +42,13 @@ static int send_file(THD *thd) old_timeout = thd->net.timeout; thd->net.timeout = thd->inactive_timeout; + // spare the stack + if(!(buf = alloc_root(&thd->mem_root,IO_SIZE))) + { + errmsg = "Out of memory"; + goto err; + } + // we need net_flush here because the client will not know it needs to send // us the file name until it has processed the load event entry if (net_flush(net) || my_net_read(net) == packet_error) @@ -62,7 +69,7 @@ static int send_file(THD *thd) goto err; } - while ((bytes = (int) my_read(fd, (byte*) buf, sizeof(buf), + while ((bytes = (int) my_read(fd, (byte*) buf, IO_SIZE, MYF(MY_WME))) > 0) { if (my_net_write(net, buf, bytes)) |