return res;
}
-static enum ast_device_state devstate_cached(const char *device)
+static enum ast_device_state devstate_cached(const char *device, const struct ast_eid *eid)
{
struct stasis_message *cached_msg;
struct ast_device_state_message *device_state;
enum ast_device_state state;
cached_msg = stasis_cache_get_by_eid(ast_device_state_cache(),
- ast_device_state_message_type(), device, NULL);
+ ast_device_state_message_type(), device, eid);
if (!cached_msg) {
return AST_DEVICE_UNKNOWN;
}
/* If the last known state is cached, just return that */
if (check_cache) {
- res = devstate_cached(device);
+ res = devstate_cached(device, NULL);
if (res != AST_DEVICE_UNKNOWN) {
return res;
}
return -1;
}
+ if (cachable) {
+ enum ast_device_state res;
+
+ /* If the state is unchanged, do not publish */
+ res = devstate_cached(device, eid);
+ if (res == state) {
+ return 0;
+ }
+ }
+
device_state = device_state_alloc(device, state, cachable, eid);
if (!device_state) {
return -1;