enum field_e {
APPLICATION_CLASS = 1,
+ AUTO_RELEASE,
RESOURCE_SET,
ATTRIBUTES,
+ DONT_WAIT,
RESOURCE,
STATE,
ID
lua_pushstring(L, state);
break;
+ case DONT_WAIT:
+ lua_pushboolean(L, rset->dont_wait.current);
+ break;
+
+ case AUTO_RELEASE:
+ lua_pushboolean(L, rset->auto_release.current);
+ break;
+
case APPLICATION_CLASS:
lua_pushstring(L, rset->class.ptr->name);
break;
static int setref_setfield(lua_State *L)
{
- MRP_UNUSED(L);
+ mrp_resource_setref_t *ref = setref_check(L, 1);
+ mrp_resource_set_t *rset;
+ field_t field;
MRP_LUA_ENTER;
- printf("*** setref setfield\n");
+ if (ref && (rset = ref->rset)) {
+ field = field_check(L, 2, NULL);
+
+ switch (field) {
+
+ case DONT_WAIT:
+ rset->dont_wait.current = lua_toboolean(L, 3);
+ break;
+
+ case AUTO_RELEASE:
+ rset->auto_release.current = lua_toboolean(L, 3);
+ break;
+
+ default:
+ break;
+ }
+ }
MRP_LUA_LEAVE(0);
}
return RESOURCE;
break;
+ case 9:
+ if (!strcmp(name, "dont_wait"))
+ return DONT_WAIT;
+ break;
+
case 10:
if (!strcmp(name, "attributes"))
return ATTRIBUTES;
break;
case 12:
+ if (!strcmp(name, "auto_release"))
+ return AUTO_RELEASE;
if (!strcmp(name, "resource_set"))
return RESOURCE_SET;
break;
/* rollback, ie. restore the backed up state */
rc = NULL;
while ((res=mrp_resource_set_iterate_resources(rset,&rc))){
- rdef = res->def;
- rid = rdef->id;
- mask = (mrp_resource_mask_t)1 << rid;
- owner = get_owner(zoneid, rid);
+ rdef = res->def;
+ rid = rdef->id;
+ mask = (mrp_resource_mask_t)1 << rid;
+ owner = get_owner(zoneid, rid);
*owner = backup[rid];
if ((grant & mask)) {
else {
if (grant == rset->resource.mask.grant) {
if (rset->state == mrp_resource_acquire &&
- !grant && rset->dont_wait)
+ !grant && rset->dont_wait.current)
{
- notify = MRP_RESOURCE_EVENT_RELEASE;
rset->state = mrp_resource_release;
+ rset->dont_wait.current = rset->dont_wait.client;
+
+ notify = MRP_RESOURCE_EVENT_RELEASE;
move = true;
}
}
rset->resource.mask.grant = grant;
changed = true;
- if (!grant && rset->auto_release) {
- if (rset->state != mrp_resource_release)
- notify = MRP_RESOURCE_EVENT_RELEASE;
+ if (rset->state != mrp_resource_release &&
+ !grant && rset->auto_release.current)
+ {
rset->state = mrp_resource_release;
+ rset->auto_release.current = rset->auto_release.client;
+
+ notify = MRP_RESOURCE_EVENT_RELEASE;
move = true;
}
}
mrp_log_error("Memory alloc failure. Can't create resource set");
else {
rset->id = ++our_id;
- rset->auto_release = auto_release;
- rset->dont_wait = dont_wait;
+
+ rset->dont_wait.current = dont_wait;
+ rset->dont_wait.client = dont_wait;
+
+ rset->auto_release.current = auto_release;
+ rset->auto_release.client = auto_release;
mrp_list_init(&rset->resource.list);
rset->resource.share = false;
MRP_ASSERT(rset && name, "invalid argument");
rsetid = rset->id;
- autorel = rset->auto_release;
+ autorel = rset->auto_release.client;
if (!(res = mrp_resource_create(name, rsetid, autorel, shared, attrs))) {
mrp_log_error("Can't add resource '%s' name to resource set %u",
mrp_resource_notify(res, rset, ev);
}
+void mrp_resource_set_request_auto_release(mrp_resource_set_t *rset,
+ bool auto_release)
+{
+ MRP_ASSERT(rset, "invalid argument");
+
+ rset->auto_release.current = auto_release;
+}
+
+void mrp_resource_set_request_dont_wait(mrp_resource_set_t *rset,
+ bool dont_wait)
+{
+ MRP_ASSERT(rset, "invalid argument");
+
+ rset->dont_wait.current = dont_wait;
+}
+
int mrp_resource_set_print(mrp_resource_set_t *rset, size_t indent,
char *buf, int len)
{
rset->resource.mask.grant, rset->resource.mask.advice,
mrp_application_class_get_sorting_key(rset), rset->class.priority,
rset->resource.share ? "shared ":"exclusive",
- rset->auto_release ? ",autorelease" : "",
- rset->dont_wait ? ",dontwait" : "",
+ rset->auto_release.client ? ",autorelease" : "",
+ rset->dont_wait.client ? ",dontwait" : "",
state_str(rset->state));
mrp_list_foreach(&rset->resource.list, resen, n) {
#include "data-types.h"
-
struct mrp_resource_set_s {
mrp_list_hook_t list;
uint32_t id;
mrp_resource_state_t state;
- bool auto_release;
- bool dont_wait;
+ struct {
+ bool current;
+ bool client;
+ } auto_release;
+ struct {
+ bool current;
+ bool client;
+ } dont_wait;
struct {
struct {
mrp_resource_mask_t all;
void mrp_resource_set_updated(mrp_resource_set_t *);
void mrp_resource_set_notify(mrp_resource_set_t *,
mrp_resource_event_t);
+void mrp_resource_set_request_auto_release(mrp_resource_set_t *,
+ bool);
+void mrp_resource_set_request_dont_wait(mrp_resource_set_t *,
+ bool);
int mrp_resource_set_print(mrp_resource_set_t *, size_t,
char *, int);