The current behavior of put_data_and_throttle leads to data
curruption, because the supplied buffer is apparently still being
written when the call returns--regardless of the value of
need_to_wait.
For now, do a buffer::copy of the supplied buffer, rather than the
original buffer::static, since that will at least be released
when no longer needed.
Probably this improves apparent rgw_write performance, but is not
what was originally intended.
Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
}
buffer::list bl;
+ /* XXXX */
+#if 0
bl.push_back(
buffer::create_static(len, static_cast<char*>(buffer)));
+#else
+ bl.push_back(
+ buffer::copy(static_cast<char*>(buffer), len));
+#endif
f->write_req->put_data(off, bl);
rc = f->write_req->exec_continue();
if (! len)
return 0;
- /* XXX won't see multipart */
- bool need_to_wait = (ofs == 0) && multipart;
+ /* XXX we are currently synchronous--supplied data buffers cannot
+ * be used after the caller returns */
+ bool need_to_wait = true;
bufferlist orig_data;
if (need_to_wait) {
<< " (" << str << "... [first 4 chars])"
<< std::endl;
}
- rc = rgw_write(fs, fobj.fh, offset, length, &nwritten, buffer,
+ char* leakbuf = (char*) malloc(bufsz);
+ memcpy(leakbuf, buffer, length);
+ rc = rgw_write(fs, fobj.fh, offset, length, &nwritten, leakbuf,
RGW_WRITE_FLAG_NONE);
ASSERT_EQ(rc, 0);
ASSERT_EQ(nwritten, length);