Exemple #1
0
static void mangoh_bridge_air_vantage_removedataUpdateHdlrs(mangoh_bridge_air_vantage_t* airVantage)
{
  LE_ASSERT(airVantage);

  if (!le_hashmap_isEmpty(airVantage->dataUpdateHandlers))
  {
    le_hashmap_It_Ref_t iter = le_hashmap_GetIterator(airVantage->dataUpdateHandlers);

    int32_t res = le_hashmap_NextNode(iter);
    while (res == LE_OK)
    {
      dataRouter_DataUpdateHandlerRef_t dataUpdateHandlerRef = (dataRouter_DataUpdateHandlerRef_t)le_hashmap_GetValue(iter);
      if (dataUpdateHandlerRef)
      {
        dataRouter_RemoveDataUpdateHandler(dataUpdateHandlerRef);
      }

      res = le_hashmap_NextNode(iter);
    }

    le_hashmap_RemoveAll(airVantage->dataUpdateHandlers);
  }
}
Exemple #2
0
//--------------------------------------------------------------------------------------------------
static void OnClientDisconnect
(
    le_msg_SessionRef_t sessionRef,
    void *contextPtr
)
{
    Client_t *c;
    WakeupSource_t *ws;
    le_hashmap_It_Ref_t iter;

    // Find and remove client record from table
    c = to_Client_t(le_hashmap_Remove(PowerManager.clients, sessionRef));
    LE_INFO("Client pid %d disconnected.", c->pid);

    // Find and remove all wakeup sources held for this client
    iter = le_hashmap_GetIterator(PowerManager.locks);
    while (LE_OK == le_hashmap_NextNode(iter)) {
        ws = (WakeupSource_t*)le_hashmap_GetValue(iter);
        if (ws->pid != c->pid)
            // Does not belong to this client, skip
            continue;

        // Release wakeup source if taken
        if (ws->taken) {
            LE_WARN("Releasing wakeup source '%s' on behalf of pid %d.",
                    ws->name, ws->pid);
            le_pm_Relax((le_pm_WakeupSourceRef_t)ws->wsref);
        }

        // Delete wakeup source record, free memory
        LE_INFO("Deleting wakeup source '%s' on behalf of pid %d.",
                ws->name, ws->pid);
        le_hashmap_Remove(PowerManager.locks, ws->name);
        le_ref_DeleteRef(PowerManager.refs, ws->wsref);
        le_mem_Release(ws);
    }

    // Free client record
    le_mem_Release(c);

    return;
}