From b139a7cd34b4e203ab164ada7a8fa590b50d8b13 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Tue, 30 Jul 2013 17:34:49 -0700 Subject: [PATCH] rgw: don't read cors attrs if there's no bucket in operation Signed-off-by: Yehuda Sadeh Reviewed-by: Josh Durgin --- src/rgw/rgw_op.cc | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index e672de154ab6..0c3f4955940b 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -2514,32 +2514,33 @@ int RGWHandler::read_cors_config(void) { int ret = 0; bufferlist bl; - + + if (s->bucket.name.empty()) + return 0; + dout(10) << "Going to read cors from attrs" << dendl; rgw_obj obj; store->get_bucket_instance_obj(s->bucket, obj); - if (obj.bucket.name.size()) { - ret = store->get_attr(s->obj_ctx, obj, RGW_ATTR_CORS, bl); - if (ret >= 0) { - bufferlist::iterator iter = bl.begin(); - s->bucket_cors = new RGWCORSConfiguration(); - try { - s->bucket_cors->decode(iter); - } catch (buffer::error& err) { - ldout(s->cct, 0) << "ERROR: could not decode policy, caught buffer::error" << dendl; - return -EIO; - } - if (s->cct->_conf->subsys.should_gather(ceph_subsys_rgw, 15)) { - RGWCORSConfiguration_S3 *s3cors = static_cast(s->bucket_cors); - ldout(s->cct, 15) << "Read RGWCORSConfiguration"; - s3cors->to_xml(*_dout); - *_dout << dendl; - } - } else { + ret = store->get_attr(s->obj_ctx, obj, RGW_ATTR_CORS, bl); + if (ret >= 0) { + bufferlist::iterator iter = bl.begin(); + s->bucket_cors = new RGWCORSConfiguration(); + try { + s->bucket_cors->decode(iter); + } catch (buffer::error& err) { + ldout(s->cct, 0) << "ERROR: could not decode policy, caught buffer::error" << dendl; + return -EIO; + } + if (s->cct->_conf->subsys.should_gather(ceph_subsys_rgw, 15)) { + RGWCORSConfiguration_S3 *s3cors = static_cast(s->bucket_cors); + ldout(s->cct, 15) << "Read RGWCORSConfiguration"; + s3cors->to_xml(*_dout); + *_dout << dendl; + } + } else { /*Not a serious error*/ dout(2) << "Warning: There is no content for CORS xattr," " cors may not be set yet" << dendl; - } } return ret; } -- 2.47.3