client: fix use-after-free on session close and cond signals

Move the signal into the closed method, before we deallocate the
MetaSession, so that other callers catch it too.

Signed-off-by: Sage Weil <sage@inktank.com>
client: do sync read when 'client oc = false'

Signed-off-by: Sage Weil <sage@inktank.com>
rgw: with CORS support

With CORS test cases

1. Added license headers to the cors files
2. SIWFT POST metadata for cors will replace the old cors configuration
3. Fixed a buf in rgw_cors_swift.h

With Yehuda's review comments along with some fixes;
1. If the origin is allowed only for https, we should not approve the same host for http requests
2. Accounted for hostname situtation like www.www.org, or www.wowwww.com or www.*
3. Replaced atoi with strtol
4. Have a centralized place for parsing host names, hence avoiding duplicates

Checked certain senarios with amazon S3 and made changes accordingly

With some fixes in rgw_cors.cc and str_list.cc

Removing the whitespace auto-append to the delimiters in get_str_list(), added white spaces delimiters in is_string_in_set()
rgw: cors, style fixes, other fixes

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
rgw: more cors fixes

Remove the check for read_cors_config in rgw_main.cc, and changes type of 'a' to unsigned from long as max_age cannot be a negative integer

Modified the type of 'a' to unsigned long and used ULONG_MAX and strtol in rgw_cors_swift.h

Signed-off-by: Babu Shanmugam <anbu@enovance.com>
rgw: fix a few warnings

Adjust data types

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
Makefile.am: change some cors rules

The cors unitest should be a standalone test (not part of the make
unitests) as it requires having a running gateway and needs input params
to run correctly.
Also update missing header files.

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
rgw: add missing include file

Add missing limits.h, needed for ULONG_MAX.

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
rgw: fix warning

On a 64-bit arch, we still want to make sure it's a 32-bit value.  Gcc is
too smart for us to just cast; it will still warn on 32-bit arch that the
comparison is always true.

Signed-off-by: Sage Weil <sage@inktank.com>
Merge remote-tracking branch 'gh/wip-cors-rebased'

Reviewed-by: Yehuda Sadeh <yehuda@inktank.com>
strings: add 'list-watchers' to MOSDOp strings

Signed-off-by: Sage Weil <sage@inktank.com>
osd: make LIST_WATCHERS and LIST_SNAPS print nicely for OSDOp

Signed-off-by: Sage Weil <sage@inktank.com>
osd: include SnapSet seq in the list snaps response

It is important to know the latest seq that the object has seen in order
to tell if a response like

 clone 2 snaps=[1,2]
 clone head snaps=[]

was untouched before a hypothetical snap 3, or deleted prior to snap 3,
and then recreated+modified after.

Signed-off-by: Sage Weil <sage@inktank.com>
osd: clean up some whitespace

Signed-off-by: Sage Weil <sage@inktank.com>
osd: do not include snaps with head on list_snaps()

If there is a sequence of snaps 1, 2, 3, 4, 5, and we have a clone
2 with [1,2], and the head reflects content at snap times [3,4,5], then
the snap_list should return

 clone 2 snaps [1,2]
 head snaps
 seq 2

because it never saw a write after snap 2, and therefor has the same
content currently as it did in snaps 3,4,5.  If the SnapSet on the
object lists snaps 3,4,5, and the head exists, it actually means the
object was deleted between 2 and 3, and was recreated after 5:

 clone 2 snaps [1,2]
 head snaps []
 seq 5

The key to telling the two situations apart is the seq number on the
SnapSet (now included in the list_snaps reply) that tells us when the
last update was.

Signed-off-by: Sage Weil <sage@inktank.com>
osd: direct reads on SNAPDIR to either head or snapdir

The list_snaps operation needs to look at the SnapSet, and is logically
querying all revisions of the object.  Make requests to SNAPDIR be
read-only, and grab the head or snapdir obc transparently (whichever one
exists).  This allows us to list snaps when, say, the head does not
exist, but there are in fact snaps.

Signed-off-by: Sage Weil <sage@inktank.com>
osd: wait for all clones on SNAPDIR requests

Wait for all clones to be present.

Signed-off-by: Sage Weil <sage@inktank.com>
osd: fix clone snap list for list-snaps

We need to return the list of snaps that each clone is defined for, not
the list of snaps we know may or may not exist globally over a similar
interval.  This requires looking at the clone's obc, unfortunately.

Signed-off-by: Sage Weil <sage@inktank.com>
osd: fix error codes for list-snaps

Signed-off-by: Sage Weil <sage@inktank.com>
osdc/Objecter: prval optional for listsnaps

Signed-off-by: Sage Weil <sage@inktank.com>