From 8fbabe03e100392f28da02c1e7f2fdbc03526bc0 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 11 May 2010 16:52:48 -0700 Subject: [PATCH] msgr: put msgvec on heap It can get too big for the stack. --- src/msg/SimpleMessenger.cc | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/msg/SimpleMessenger.cc b/src/msg/SimpleMessenger.cc index 5a9eb02e1181d..5874b829d5042 100644 --- a/src/msg/SimpleMessenger.cc +++ b/src/msg/SimpleMessenger.cc @@ -1951,6 +1951,7 @@ int SimpleMessenger::Pipe::write_message(Message *m) { ceph_msg_header& header = m->get_header(); ceph_msg_footer& footer = m->get_footer(); + int ret; // get envelope, buffers header.front_len = m->get_payload().length(); @@ -1968,7 +1969,7 @@ int SimpleMessenger::Pipe::write_message(Message *m) // set up msghdr and iovecs struct msghdr msg; memset(&msg, 0, sizeof(msg)); - struct iovec msgvec[3 + blist.buffers().size()]; // conservative upper bound + struct iovec *msgvec = new iovec[3 + blist.buffers().size()]; // conservative upper bound msg.msg_iov = msgvec; int msglen = 0; @@ -2009,7 +2010,8 @@ int SimpleMessenger::Pipe::write_message(Message *m) while (left > 0) { int donow = MIN(left, (int)pb->length()-b_off); if (donow == 0) { - dout(0) << "donow = " << donow << " left " << left << " pb->length " << pb->length() << " b_off " << b_off << dendl; + dout(0) << "donow = " << donow << " left " << left << " pb->length " << pb->length() + << " b_off " << b_off << dendl; } assert(donow > 0); dout(30) << " bl_pos " << bl_pos << " b_off " << b_off @@ -2020,7 +2022,7 @@ int SimpleMessenger::Pipe::write_message(Message *m) if (msg.msg_iovlen >= IOV_MAX-2) { if (do_sendmsg(sd, &msg, msglen, true)) - return -1; + goto fail; // and restart the iov msg.msg_iov = msgvec; @@ -2037,7 +2039,8 @@ int SimpleMessenger::Pipe::write_message(Message *m) assert(left >= 0); b_off += donow; bl_pos += donow; - if (left == 0) break; + if (left == 0) + break; while (b_off == (int)pb->length()) { pb++; b_off = 0; @@ -2053,9 +2056,17 @@ int SimpleMessenger::Pipe::write_message(Message *m) // send if (do_sendmsg(sd, &msg, msglen)) - return -1; + goto fail; - return 0; + ret = 0; + + out: + delete[] msgvec; + return ret; + + fail: + ret = -1; + goto out; } -- 2.39.5