コード例 #1
0
inline static void
kogmo_rtdb_heap_unlock (kogmo_rtdb_handle_t *db_h)
{
    kogmo_rtdb_ipc_mutex_unlock(&db_h->localdata_p->heap_lock);
}
コード例 #2
0
int
kogmo_rtdb_objmeta_purge_procs (kogmo_rtdb_handle_t *db_h)
{
  int i;
  kogmo_rtdb_objid_t err;

  CHK_DBH("kogmo_rtdb_objmeta_purge_procs",db_h,0);

  for(i=0;i<KOGMO_RTDB_PROC_MAX;i++)
    {
      if(db_h->ipc_h.shm_p->proc[i].proc_oid != 0 )
        {
          err = kill ( db_h->ipc_h.shm_p->proc[i].pid , 0);
          if ( err == -1 && errno == ESRCH )
            {
              kogmo_rtdb_obj_info_t used_objmeta;
              kogmo_rtdb_objid_list_t objlist;
              int j, immediately_delete;
              kogmo_rtdb_objid_t err;

              immediately_delete = db_h->ipc_h.shm_p->proc[i].flags & KOGMO_RTDB_CONNECT_FLAGS_IMMEDIATELYDELETE;

              DBGL(DBGL_APP,"DEAD PROCESS: %s [OID %lli, PID %i]",
                      db_h->ipc_h.shm_p->proc[i].name,
                      (long long int)db_h->ipc_h.shm_p->proc[i].proc_oid,
                      db_h->ipc_h.shm_p->proc[i].pid);

              err = kogmo_rtdb_obj_searchinfo_deleted (db_h, "", 0, 0,
                        db_h->ipc_h.shm_p->proc[i].proc_oid, 0, objlist, 0);
              if (err < 0 )
                {
                  DBGL(DBGL_APP,"search for objectlist failed: %d",err);
                }
              else
                {
                  DBGL(DBGL_APP,"dead process has %i objects to%s delete",err,
                       immediately_delete ? " immediately":"");
                  for (j=0; objlist[j] != 0; j++ )
                    {
                      err = kogmo_rtdb_obj_readinfo (db_h, objlist[j], 0, &used_objmeta );
                      if ( err >= 0 && used_objmeta.flags.persistent )
                        {
                          DBGL(DBGL_APP,"keeping persistent object '%s'",used_objmeta.name);
                          continue;
                        }
                       else
                         {
                           used_objmeta.oid = objlist[j]; // enough for delete
                         }
                        kogmo_rtdb_obj_delete_imm(db_h, &used_objmeta, immediately_delete);
                    }
                }

              kogmo_rtdb_ipc_mutex_lock (&db_h->ipc_h.shm_p->proc_lock);
              memset(&db_h->ipc_h.shm_p->proc[i],0,sizeof(struct kogmo_rtdb_ipc_process_t));
              db_h->ipc_h.shm_p->proc_free++;
              kogmo_rtdb_ipc_mutex_unlock (&db_h->ipc_h.shm_p->proc_lock);
            }
        }
    }
  return 0;
}