Fixed simpleclient crash caused by curResource being altered
Fixed simpleclient crash caused by curResource being altered

The foundResource function is called asynchronously, and was written
in a way that was not thread safe. This fix adds a lock and exit logic
so that it works prooperly and only uses the first found curResource
that matches its requirements.

NOTE: This change (author: Erich Keane) is from 01.org.

Change-Id: I984ce1623ff491713ecf5d621f1283ebad33bfef
Signed-Off-by:Sudarshan Prasad<18992b2df49d20c769d3f89a8cc0a9f38a9dccaa@intel.com>
Signed-Off-by: Erich Keane <ec9f61fe526c14bb62c55d7c978f025ee6b3583d@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/236
Tested-by: jenkins-iotivity <09cb29e8a2b473a2c978382eec13ee06fa017bda@opendaylight.org>

santais/iotivity_1.1.0,santais/iotivity_1.1,santais/iotivity_1.1,santais/iotivity,santais/iotivity,santais/iotivity_1.1,santais/iotivity,tienfuc/iotivity-democlient-snap,tienfuc/iotivity-democlient-snap,santais/iotivity_1.1,santais/iotivity_1.1,tienfuc/iotivity-democlient-snap,iotivity/iotivity,santais/iotivity,santais/iotivity_1.1.0,tienfuc/iotivity-democlient-snap,WojciechLuczkow/iotivity,santais/iotivity_1.1,WojciechLuczkow/iotivity,kartben/iotivity,rzr/iotivity,kartben/iotivity,santais/iotivity_1.1.0,kartben/iotivity,santais/iotivity,rzr/iotivity,WojciechLuczkow/iotivity,kartben/iotivity,rzr/iotivity,iotivity/iotivity,kartben/iotivity,iotivity/iotivity,santais/iotivity_1.1,santais/iotivity_1.1.0,iotivity/iotivity,iotivity/iotivity,kartben/iotivity,kartben/iotivity,iotivity/iotivity,WojciechLuczkow/iotivity,iotivity/iotivity,santais/iotivity,santais/iotivity,kartben/iotivity,tienfuc/iotivity-democlient-snap,WojciechLuczkow/iotivity,santais/iotivity_1.1,rzr/iotivity,rzr/iotivity,santais/iotivity_1.1.0,rzr/iotivity,rzr/iotivity,tienfuc/iotivity-democlient-snap,iotivity/iotivity,tienfuc/iotivity-democlient-snap,WojciechLuczkow/iotivity,tienfuc/iotivity-democlient-snap,santais/iotivity_1.1.0,WojciechLuczkow/iotivity,tienfuc/iotivity-democlient-snap,santais/iotivity_1.1.0,tienfuc/iotivity-democlient-snap,WojciechLuczkow/iotivity