Skip to content

Commit

Permalink
[mce-sensorfw] Do not retry loading of unavailable sensors. JB#41369
Browse files Browse the repository at this point in the history
Now that it is possible for sensorfwd to refuse loading a sensor plugin
(due to the device not having such sensor), this can trigger MCE into
perpetual retry-in-N-seconds D-Bus IPC loop.

Differentiate between "sensor was not loaded" replies and "there were
issues while requesting sensor load" error replies - so that former
is taken to mean that the sensor is not available, and the latter as
something that might be helped with retrying a bit later.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed May 25, 2018
1 parent 567a5f6 commit c1fb3a2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
14 changes: 12 additions & 2 deletions mce-sensorfw.c
Expand Up @@ -702,6 +702,9 @@ typedef enum
/** Something went wrong */
PLUGIN_ERROR,

/** Plugin not available */
PLUGIN_NA,

PLUGIN_NUMSTATES
} sfw_plugin_state_t;

Expand Down Expand Up @@ -2654,6 +2657,7 @@ sfw_plugin_state_name(sfw_plugin_state_t state)
[PLUGIN_LOADING] = "LOADING",
[PLUGIN_LOADED] = "LOADED",
[PLUGIN_ERROR] = "ERROR",
[PLUGIN_NA] = "NA",
};

return (state < PLUGIN_NUMSTATES) ? lut[state] : 0;
Expand Down Expand Up @@ -2823,6 +2827,7 @@ sfw_plugin_trans(sfw_plugin_t *self, sfw_plugin_state_t state)
case PLUGIN_IDLE:
case PLUGIN_ERROR:
case PLUGIN_INITIAL:
case PLUGIN_NA:
sfw_plugin_do_session_reset(self);

if( self->plg_state == PLUGIN_ERROR )
Expand Down Expand Up @@ -2931,6 +2936,7 @@ sfw_plugin_load_cb(DBusPendingCall *pc, void *aptr)
DBusMessage *rsp = 0;
DBusError err = DBUS_ERROR_INIT;
dbus_bool_t ack = FALSE;
bool nak = true;

if( !pc || !self || pc != self->plg_load_pc )
goto EXIT;
Expand Down Expand Up @@ -2958,13 +2964,17 @@ sfw_plugin_load_cb(DBusPendingCall *pc, void *aptr)
goto EXIT;
}

nak = false;

EXIT:

if( self->plg_state == PLUGIN_LOADING) {
if( ack )
if( nak )
sfw_plugin_trans(self, PLUGIN_ERROR);
else if( ack )
sfw_plugin_trans(self, PLUGIN_LOADED);
else
sfw_plugin_trans(self, PLUGIN_ERROR);
sfw_plugin_trans(self, PLUGIN_NA);
}

if( rsp ) dbus_message_unref(rsp);
Expand Down
13 changes: 7 additions & 6 deletions mce-sensorfw.dot
Expand Up @@ -116,15 +116,16 @@ digraph mce_sensorfw
PLUGIN_LOADING;
PLUGIN_LOADED;
PLUGIN_ERROR;
PLUGIN_NA;
PLUGIN_ANY [label="*"];

PLUGIN_ANY -> PLUGIN_IDLE [label="reset()"];
PLUGIN_IDLE -> PLUGIN_LOADING [label="load()"];
PLUGIN_ANY -> PLUGIN_IDLE [label="reset()"];
PLUGIN_IDLE -> PLUGIN_LOADING [label="load()"];
PLUGIN_LOADING -> PLUGIN_NA [label="not-available"];
PLUGIN_LOADING -> PLUGIN_LOADED [label="loaded"];
PLUGIN_ANY -> PLUGIN_ERROR [label="failure"];

PLUGIN_LOADING -> PLUGIN_LOADED;
PLUGIN_ANY -> PLUGIN_ERROR [label="failure"];

PLUGIN_LOADED -> SESSION_IDLE [style=dotted, lhead=clusterSESSION];
PLUGIN_LOADED -> SESSION_IDLE [style=dotted, lhead=clusterSESSION];

PLUGIN_ERROR -> PLUGIN_LOADING [label="retry"];
}
Expand Down

0 comments on commit c1fb3a2

Please sign in to comment.