Beispiel #1
0
/**
 *
 * Method Name: TerminateRTCPConnection
 *
 *
 * Inputs:   IRTCPConnection *piRTCPConnection
 *                     - The Connection Interface pointer returned on creation
 *
 * Outputs:  None
 *
 * Returns:  bool
 *
 * Description:  The TerminateRTCPConnection() method shall manage the
 *               termination of and RTCP session.  This shall include the
 *               graceful release of all associated objects as well as the
 *               deallocation of all resources associated with each contained
 *               RTCP connection.
 *
 *
 * Usage Notes:
 *
 *
 */
bool CRTCPSession::TerminateRTCPConnection(IRTCPConnection *piRTCPConnection)
{
    CRTCPConnection *poRTCPConnection;

    // Remove the RTCP Connection object from the collection list
    if((poRTCPConnection = RemoveEntry(RTCPConnectionComparitor,
                                      (void *)piRTCPConnection)) != NULL)
    {
        
#if RTCP_DEBUG /* [ */
        if(bPingtelDebug)
        {
            osPrintf("*** RTCP CONNECTION TERMINATED ****\n");
            osPrintf("\t ON SESSION ==> %d\n", GetSessionID());
            osPrintf("\t TO SSRC    ==> %u\n",
                                           piRTCPConnection->GetRemoteSSRC());
        }
#endif /* RTCP_DEBUG ] */

        // Terminate RTCPConnection and release reference
        poRTCPConnection->Terminate();

        // Release reference twice.  Once for its removal from the collection
        //  and once on behalf fo the client since this method serves to
        //  terminate the connection and release the client's reference.
        ((IRTCPConnection *)poRTCPConnection)->Release();
        ((IRTCPConnection *)poRTCPConnection)->Release();

        return(TRUE);
    }

    return(FALSE);
}
void ScoreBoardManager::AddEntry( uint32_t inPlayerId, const string& inPlayerName )
{
	//if this player id exists already, remove it first- it would be crazy to have two of the same id
	RemoveEntry( inPlayerId );
	
	mEntries.emplace_back( inPlayerId, inPlayerName, mDefaultColors[ (inPlayerId - 1) % mDefaultColors.size() ] );
}
Beispiel #3
0
bool MapWStrToInt::Remove(const WCHAR *key, int *removedValOut)
{
    uintptr_t removedVal;
    bool removed = RemoveEntry(h, &gStrKeyHasherComparator, (uintptr_t)key, &removedVal);
    if (removed && removedValOut)
        *removedValOut = (int)removedVal;
    return removed;
}
Beispiel #4
0
BOOL CIniFile::WriteDword(LPCSTR pszSection, LPCSTR pszEntry, DWORD dwValue, DWORD dwDefault)
{
	if (dwValue == dwDefault)
	{
		return RemoveEntry(pszSection, pszEntry);
	}
	else
	{
		return WriteDword(pszSection, pszEntry, dwValue);
	}
}
Beispiel #5
0
BOOL CIniFile::WriteInteger(LPCSTR pszSection, LPCSTR pszEntry, int nValue, int nDefault)
{
	if (nValue == nDefault)
	{
		return RemoveEntry(pszSection, pszEntry);
	}
	else
	{
		return WriteInteger(pszSection, pszEntry, nValue);
	}
}
Beispiel #6
0
BOOL CIniFile::WriteUnsignedInteger(LPCSTR pszSection, LPCSTR pszEntry, UINT uValue, UINT uDefault)
{
	if (uValue == uDefault)
	{
		return RemoveEntry(pszSection, pszEntry);
	}
	else
	{
		return WriteInteger(pszSection, pszEntry, uValue);
	}
}
Beispiel #7
0
BOOL CIniFile::WriteLong(LPCSTR pszSection, LPCSTR pszEntry, long lValue, long lDefault)
{
	if (lValue == lDefault)
	{
		return RemoveEntry(pszSection, pszEntry);
	}
	else
	{
		return WriteLong(pszSection, pszEntry, lValue);
	}
}
Beispiel #8
0
BOOL CPrinterInfo::WriteProfileFixed(LPCSTR pEntry, CFixed cfValue, CFixed cfDefault)
{
	if (cfValue == cfDefault)
	{
		return RemoveEntry(pEntry);
	}
	else
	{
	/* Unconditional write. */
		return WriteProfileFixed(pEntry, cfValue);
	}
}
Beispiel #9
0
BOOL CPrinterInfo::WriteProfileInt(LPCSTR pEntry, UINT wValue, UINT wDefault)
{
	if (wValue == wDefault)
	{
		return RemoveEntry(pEntry);
	}
	else
	{
	/* Unconditional write. */
		return WriteProfileInt(pEntry, wValue);
	}
}
Beispiel #10
0
char SyncLogger::getModDependingOnOtherEntries(const char* pszHash, const string strFilePath, const char chType) {
	/* get the whole list with iterator */
	list<SyncLogEntry> entrylist = GetEntries(pszHash, strFilePath);
	list<SyncLogEntry>::iterator iter;
	char modType = (char)0;

	/* search for entries on given path and delete ALL... */
	for (iter = entrylist.begin(); iter != entrylist.end(); iter++) {
		SyncLogEntry sle = (SyncLogEntry)*iter;
		if (sle == strFilePath) {
			/* ... but store FIRST modification type */
			if ((int)modType == 0)
				modType = sle.GetModType();
			RemoveEntry(pszHash, sle);
		}
	}
	
	/* determine the correct modtype of the entry */
	switch (modType) {
	    case 'c': //Not Exist
		if (chType == 'c')
			return 'c'; //c + c => c
		else if (chType == 'm')
			return 'c'; //c + m => c
		else if (chType == 'd')
			return 'x'; //c + d => none (nothing to do)
		break;

	    case 'm': //Exist
		if (chType == 'c')
			return 'm'; //m + c => m
		else if (chType == 'm')
			return 'm'; //m + m => m
		else if (chType == 'd')
			return 'd'; //m + d => d
		break;

	    case 'd': //Exist
		if (chType == 'c')
			return 'm'; //d + c => m
		else if (chType == 'm')
			return 'm'; //d + m => m
		else if (chType == 'd')
			return 'd'; //d + d => d
		break;

	    default: //no earlier entry found
		return chType; //return new entry type
	}
	
	return chType; //return unknown change type
}
Beispiel #11
0
	void Core::handleEntryShouldBeRemoved ()
	{
		MetaEntry *entry = qobject_cast<MetaEntry*> (sender ());
		if (!entry)
		{
			qWarning () << Q_FUNC_INFO
					<< "unable to cast"
					<< sender ()
					<< "to MetaEntry*";
			return;
		}

		RemoveEntry (entry);
	}
Beispiel #12
0
void DataArchive::Remove(const char* name)
{
   int index = FindEntry(name);

   if (index < 0) {
      printf("Could not remove '%s', not found\n", name);
      return;
   }

   RemoveEntry(index);
   WriteEntry(index, 0);

   if (verbose) printf("   Removed: %s\n", name);
}
Beispiel #13
0
	void RoomHandler::handleMessagesAreRead ()
	{
		RoomParticipantEntry *entry = qobject_cast<RoomParticipantEntry*> (sender ());
		if (!entry)
		{
			qWarning () << Q_FUNC_INFO
					<< sender ()
					<< "is not a RoomParticipantEntry";
			return;
		}

		if (entry->GetStatus (QString ()).State_ == SOffline)
			RemoveEntry (entry);
	}
Beispiel #14
0
	void RoomHandler::handleParticipantRemoved (const QString& jid)
	{
		const QXmppPresence& pres = Room_->participantPresence (jid);

		QString nick;
		ClientConnection::Split (jid, 0, &nick);

		const bool us = Room_->nickName () == nick;

		RoomParticipantEntry_ptr entry = GetParticipantEntry (nick);
		const QXmppMucItem& item = pres.mucItem ();
		if (!item.nick ().isEmpty () &&
				item.nick () != nick)
		{
			entry->SetEntryName (item.nick ());
			Nick2Entry_ [item.nick ()] = Nick2Entry_ [nick];
			MakeNickChangeMessage (nick, item.nick ());
			Nick2Entry_.remove (nick);
			PendingNickChanges_ << item.nick ();
			return;
		}
		else if (pres.mucStatusCodes ().contains (301))
			!us ?
				MakeBanMessage (nick, item.reason ()) :
				static_cast<void> (QMetaObject::invokeMethod (CLEntry_,
							"beenBanned",
							Qt::QueuedConnection,
							Q_ARG (QString, item.reason ())));
		else if (pres.mucStatusCodes ().contains (307))
			!us ?
				MakeKickMessage (nick, item.reason ()) :
				static_cast<void> (QMetaObject::invokeMethod (CLEntry_,
							"beenKicked",
							Qt::QueuedConnection,
							Q_ARG (QString, item.reason ())));
		else
			MakeLeaveMessage (pres, nick);

		if (us)
		{
			Leave (QString (), false);
			return;
		}

		if (entry->HasUnreadMsgs ())
			entry->SetStatus (EntryStatus (SOffline, item.reason ()), QString ());
		else
			RemoveEntry (entry.get ());
	}
Beispiel #15
0
int
osi_dnlc_remove(struct vcache *adp, char *aname, struct vcache *avc)
{
    unsigned int key, skey;
    char *ts = aname;
    struct nc *tnc;

    if (!afs_usednlc)
	return 0;

    TRACE(osi_dnlc_removeT, skey);
    dnlcHash(ts, key);		/* leaves ts pointing at the NULL */
    if (ts - aname >= AFSNCNAMESIZE) {
	return 0;
    }
    skey = key & (NHSIZE - 1);
    TRACE(osi_dnlc_removeT, skey);
    dnlcstats.removes++;
    ObtainReadLock(&afs_xdnlc);

    for (tnc = nameHash[skey]; tnc; tnc = tnc->next) {
	if ((tnc->dirp == adp) && (tnc->key == key)
	    && (!strcmp((char *)tnc->name, aname))) {
	    tnc->dirp = NULL;	/* now it won't match anything */
	    break;
	} else if (tnc->next == nameHash[skey]) {	/* end of list */
	    tnc = NULL;
	    break;
	}
    }
    ReleaseReadLock(&afs_xdnlc);

    if (!tnc)
	return 0;

    /* there is a little race condition here, but it's relatively
     * harmless.  At worst, I wind up removing a mapping that I just
     * created. */
    if (EWOULDBLOCK == NBObtainWriteLock(&afs_xdnlc, 1)) {
	return 0;		/* no big deal, tnc will get recycled eventually */
    }
    RemoveEntry(tnc, skey);
    tnc->next = ncfreelist;
    ncfreelist = tnc;
    ReleaseWriteLock(&afs_xdnlc);

    return 0;
}
    std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t> MidiInstrumentMapper::Entries(int Map) throw (Exception) {
        std::map<midi_prog_index_t,entry_t> result;

        // copy the internal map first
        midiMapsMutex.Lock();
        std::map<int,MidiInstrumentMap>::iterator iterMap = midiMaps.find(Map);
        if (iterMap == midiMaps.end()) { // no such map
            midiMapsMutex.Unlock();
            throw Exception("There is no MIDI instrument map " + ToString(Map));
        }
        for (std::map<midi_prog_index_t,private_entry_t>::iterator iterEntry = iterMap->second.begin();
             iterEntry != iterMap->second.end(); iterEntry++)
        {
            entry_t entry;
            entry.EngineName      = iterEntry->second.EngineName;
            entry.InstrumentFile  = iterEntry->second.InstrumentFile;
            entry.InstrumentIndex = iterEntry->second.InstrumentIndex;
            entry.Volume          = iterEntry->second.Volume;
            entry.Name            = iterEntry->second.Name;
            result[iterEntry->first] = entry;
        }
        midiMapsMutex.Unlock();

        // complete it with current LoadMode of each entry
        for (std::map<midi_prog_index_t,entry_t>::iterator iter = result.begin();
             iter != result.end(); iter++)
        {
            entry_t& entry = iter->second;
            Engine* pEngine = EngineFactory::Create(entry.EngineName);
            if (!pEngine) { // invalid mapping
                RemoveEntry(Map, iter->first);
                result.erase(iter);
                continue;
            }
            InstrumentManager* pManager = pEngine->GetInstrumentManager();
            if (pManager) { // engine provides an InstrumentManager
                InstrumentManager::instrument_id_t id;
                id.FileName = entry.InstrumentFile;
                id.Index    = entry.InstrumentIndex;
                entry.LoadMode = static_cast<mode_t>(pManager->GetMode(id));
            } else { // engine does not provide an InstrumentManager
                // use default value
                entry.LoadMode = ON_DEMAND;
            }
            EngineFactory::Destroy(pEngine);
        }
        return result;
    }
//-------------------------------------------------------------------------------------------------
int StringTable::Remove( const char *text, void *data ) {
	int index = -1;
	if( text != 0 ) {
		// use text
		index = QueryIndex( text );
	} else if( data != 0 ) {
		index = QueryIndex( 0, data );
	} else {
		return REMOVESTRING_NOPARAMETERS;
	}

	if( index == -1 ) return REMOVESTRING_NOTFOUND;

	RemoveTextData( index );
	RemoveEntry( index );
	
	return REMOVESTRING_COMPLETED;
}
Beispiel #18
0
// Delete an entry
VXIcacheResult SBcacheManager::Delete(VXIlogInterface   *log,
				      const SBcacheKey  &key,
				      bool               haveEntryOpen)
{
  VXIcacheResult rc = VXIcache_RESULT_SUCCESS;

  // Find the entry and delete it, only need read permission. Note
  // that we need to hold a reference to the entry in order to make
  // sure it only gets deleted after we release our lock here (that
  // may be a costly operation). The extra braces ensure the actual
  // deletion is done prior to logging our exit.
  {
    SBcacheEntry entry;

    if ( _entryTableMutex.Lock( ) != VXItrd_RESULT_SUCCESS ) {
      Error (log, 110, L"%s%s", L"mutex", L"entry table mutex");
      rc = VXIcache_RESULT_SYSTEM_ERROR;
    } else {
      SBcacheEntryTable::iterator vi = _entryTable.find (key);
      if ( vi != _entryTable.end( ) ) {
	entry = (*vi).second;
        RemoveEntry(entry);
      } else {
	rc = VXIcache_RESULT_NOT_FOUND;
      }

      if ( _entryTableMutex.Unlock( ) != VXItrd_RESULT_SUCCESS ) {
	Error (log, 111, L"%s%s", L"mutex", L"entry table mutex");
	rc = VXIcache_RESULT_SYSTEM_ERROR;
      }
    }

    // Note that even getting the size can take time since we
    // may lock on a write mutex until some write is done, and note that
    // erasing the entries may take time since that involves deleting
    // on-disk files in the usual case where there are no active streams
    // for the entry.
    if ( rc == VXIcache_RESULT_SUCCESS )
      _curSizeBytes.Decrement (entry.GetSizeBytes (haveEntryOpen));
  }

  Diag (log, SBCACHE_MGR_TAGID, L"Delete", L"%s: rc = %d", key.c_str( ), rc);
  return rc;
}
Beispiel #19
0
/*!
 * Remove anything pertaining to this file
 *
 * \param File vcache entry.
 * \return 0
 */
int
osi_dnlc_purgevp(struct vcache *avc)
{
    int i;
    int writelocked;

#ifdef AFS_DARWIN_ENV
    if (!(avc->f.states & (CVInit | CVFlushed
#ifdef AFS_DARWIN80_ENV
                        | CDeadVnode
#endif
        )) && AFSTOV(avc))
    cache_purge(AFSTOV(avc));
#endif

    if (!afs_usednlc)
	return 0;

    dnlcstats.purgevs++;
    TRACE(osi_dnlc_purgevpT, 0);
    writelocked = (0 == NBObtainWriteLock(&afs_xdnlc, 3));

    for (i = 0; i < NCSIZE; i++) {
	if (nameCache[i].vp == avc) {
	    nameCache[i].dirp = nameCache[i].vp = NULL;
	    /* can't simply break; because of hard links -- might be two */
	    /* different entries with same vnode */
	    if (writelocked && nameCache[i].prev) {
		RemoveEntry(&nameCache[i], nameCache[i].key & (NHSIZE - 1));
		nameCache[i].next = ncfreelist;
		ncfreelist = &nameCache[i];
	    }
	}
    }
    if (writelocked)
	ReleaseWriteLock(&afs_xdnlc);

    return 0;
}
void
LauncherEntryRemoteModel::OnDBusNameOwnerChanged(GDBusConnection* connection,
                                                 const gchar* sender_name,
                                                 const gchar* object_path,
                                                 const gchar* interface_name,
                                                 const gchar* signal_name,
                                                 GVariant* parameters,
                                                 gpointer user_data)
{
  auto self = static_cast<LauncherEntryRemoteModel*>(user_data);

  if (!parameters || self->_entries_by_uri.empty())
    return;

  glib::String name, before, after;
  g_variant_get(parameters, "(sss)", &name, &before, &after);

  if (!after || after.Str().empty())
  {
    // Name gone, find and destroy LauncherEntryRemote
    std::vector<LauncherEntryRemote::Ptr> to_rm;

    for (auto it = self->_entries_by_uri.begin(); it != self->_entries_by_uri.end(); ++it)
    {
      auto entry = it->second;

      if (entry->DBusName() == name.Str())
      {
        to_rm.push_back(entry);
      }
    }

    for (auto entry : to_rm)
    {
      self->RemoveEntry(entry);
    }
  }
}
Beispiel #21
0
	void GlooxAccount::RemoveEntry (QObject *entryObj)
	{
		auto entry = qobject_cast<GlooxCLEntry*> (entryObj);
		if (!entry)
		{
			qWarning () << Q_FUNC_INFO
					<< entryObj
					<< "is not a GlooxCLEntry";
			return;
		}

		if (entry->IsGateway ())
		{
			const auto& allEntries = ClientConnection_->GetCLEntries ();

			const auto& gwJid = entry->GetJID ();

			QList<GlooxCLEntry*> subs;
			for (auto obj : allEntries)
			{
				auto otherEntry = qobject_cast<GlooxCLEntry*> (obj);
				if (otherEntry &&
						otherEntry != entry &&
						otherEntry->GetJID ().endsWith (gwJid))
					subs << otherEntry;
			}

			if (!subs.isEmpty ())
			{
				GWItemsRemovalDialog dia (subs);
				if (dia.exec () == QDialog::Accepted)
					for (auto subEntry : subs)
						RemoveEntry (subEntry);
			}
		}

		ClientConnection_->Remove (entry);
	}
Beispiel #22
0
/*!
 * Remove anything pertaining to this directory.  I can invalidate
 * things without the lock, since I am just looking through the array,
 * but to move things off the lists or into the freelist, I need the
 * write lock
 *
 * \param adp vcache entry for the directory to be purged.
 * \return 0
 */
int
osi_dnlc_purgedp(struct vcache *adp)
{
    int i;
    int writelocked;

#ifdef AFS_DARWIN_ENV
    if (!(adp->f.states & (CVInit | CVFlushed
#ifdef AFS_DARWIN80_ENV
                        | CDeadVnode
#endif
        )) && AFSTOV(adp))
    cache_purge(AFSTOV(adp));
#endif

    if (!afs_usednlc)
	return 0;

    dnlcstats.purgeds++;
    TRACE(osi_dnlc_purgedpT, 0);
    writelocked = (0 == NBObtainWriteLock(&afs_xdnlc, 2));

    for (i = 0; i < NCSIZE; i++) {
	if ((nameCache[i].dirp == adp) || (nameCache[i].vp == adp)) {
	    nameCache[i].dirp = nameCache[i].vp = NULL;
	    if (writelocked && nameCache[i].prev) {
		RemoveEntry(&nameCache[i], nameCache[i].key & (NHSIZE - 1));
		nameCache[i].next = ncfreelist;
		ncfreelist = &nameCache[i];
	    }
	}
    }
    if (writelocked)
	ReleaseWriteLock(&afs_xdnlc);

    return 0;
}
Beispiel #23
0
void Apertures::CleanUpApertures()
{
  if(verbose) cout << __FILE__ << " " << __PRETTY_FUNCTION__ << " line " << __LINE__ << " start verbose=" << verbose << " Noent()=" << Noent() << '\n';
  unsigned int Noent_prev=Noent();

  unsigned int iprinted=0;
  unsigned int PriMax=20;
  if(verbose>1) PriMax=100;

  unsigned int nRedundant=0;
  for(unsigned int i=0;i<Noent()-1;++i) // remove redundant values     same s and aper_1
  {
    if(svec[i+1]<=svec[i] && aper_1_vec[i]==aper_1_vec[i+1] )
    {
      if(i<PriMax)
      {
        cout << " s does not increase, and same aperture remove entry i+1=" << i+1 << '\n';
        Print(i,i+1);
      }
      RemoveEntry(i+1);
      nRedundant++;
    }
    iprinted++;
  }
  if(verbose) cout << __FILE__ << " " << __PRETTY_FUNCTION__ << " line " << __LINE__ << " after deleting " << Noent_prev-Noent() << " redundant apertures Noent()=" << Noent() << '\n';
  Noent_prev=Noent();

  unsigned int nFixOldIP=0;
  for(unsigned int i=0;i<Noent()-1;++i) // special fix for old beam pipe IP marker sizes
  {
    if(StartsWith(AperName[i],"IP"))
    {
      if(aper_1_vec[i]>aper_1_vec[i+1])
      {
        cout << " work on entry with AperName[" << i << "]=" << AperName[i] << '\n';
        Print(i,i+1);
        cout << " set historic larger value " << aper_1_vec[i] << " to the smaller new value " << aper_1_vec[i+1] << '\n';
        aper_1_vec[i] = aper_1_vec[i+1];
        nFixOldIP++;
      }
    }
  }

  iprinted=0;
  unsigned int nRectEll2Circle=0;
  unsigned int nRectEll2Ell=0;
  if(AperKeyw.size()>0)
  {
    for(unsigned int i=0;i<Noent()-1;++i) // simplify RECTELLIPSE which are in fact CIRCLES
    {
      if(AperType[i]=="RECTELLIPSE")
      {
        if(aper_1_vec[i]==aper_2_vec[i] && aper_1_vec[i]==aper_3_vec[i] && aper_3_vec[i]==aper_4_vec[i])  // all equal, this is a circle
        {
          if(i<PriMax)
          {
            cout << " simplify AperName[" << i << "]=" << AperName[i] << '\n';
            Print(i,i);
          }
          AperType[i]="CIRCLE";
          aper_2_vec[i]=aper_3_vec[i]=aper_4_vec[i]=0;
          nRectEll2Circle++;
          if(i<PriMax)
          {
            cout << "  to circle" << '\n';
            Print(i,i);
          }
          iprinted++;
        }
        // check if there are rectangle which are larger than the ellipse, simplify to ELLIPSE
        else if(aper_1_vec[i]>=aper_3_vec[i] && aper_2_vec[i]>=aper_4_vec[i])
        {
          if(i<PriMax)
          {
            cout << " simplify AperName[" << i << "]=" << AperName[i] << '\n';
            Print(i,i);
          }
          AperType[i]="ELLIPSE";
          aper_1_vec[i]=aper_3_vec[i];
          aper_2_vec[i]=aper_4_vec[i];
          aper_3_vec[i]=aper_4_vec[i]=0;
          nRectEll2Ell++;
          if(i<PriMax)
          {
            cout << "  to ellipse" << '\n';
            Print(i,i);
          }
          iprinted++;
        }
      }
    }
  }
  cout << "done with CleanUpApertures"
  << " nRedundant=" << nRedundant
  << " nFixOldIP=" << nFixOldIP
  << " nRectEll2Circle=" << nRectEll2Circle
  << " nRectEll2Ell=" << nRectEll2Ell
  << " Noent()=" << Noent()
  << '\n';
}
Beispiel #24
0
/*|><|************************************************************************
*
* Method Name:  MessageLoop
*
*
* Inputs:       None
*
* Outputs:      None
*
* Returns:      None
*
* Logic Notes:
*
* Caveats:
*
************************************************************************|<>|*/
void CMsgQueue::MessageLoop()
{

    // Establish an array of event on which we are to wait.  Among these
    // events are the message Arrival event and the Thread Termination event.
    HANDLE hEventList[] = {m_hThreadEvent, m_hMessageEvent};
    unsigned long dwEvents = 2;
    BOOL bTerminate = FALSE;

//  Sleep briefly to allow the parent thread to run and pickup the thread
//  initialization signal.
    Sleep(ONE_SECOND);

    while (!bTerminate)
    {

        // Wait for an Event to occur or for the timeout to expire
        unsigned long dwRetValue = WaitForMultipleObjects (
                dwEvents,           // Number of event objects passed in list
                hEventList,         // List of Event objects
                FALSE,              // Do not wait for all to be signalled
                ONE_SECOND);        // Wait timer duration - One Second


        // An Event was Detected.  Let's determine the event type.
        if (dwRetValue  != WAIT_TIMEOUT)
        {
            // Determine which object has signalled us by taking the return
            // value and subtracting the base value of WAIT_OBJECT_0 from it
            unsigned long dwIndex = dwRetValue - WAIT_OBJECT_0;

            // If the object that signalled us is Index 0, it is the terminate
            // thread object.  Let's break out of the while loop and tend to
            // gracefully shutting down the Message processing thread.
            if (dwIndex == 0 || dwIndex > dwEvents)
            {
                // Terminate message processing
                bTerminate = TRUE;
            }
            else
            {
                // Reset Index and Event
                dwIndex = 0;
                ResetEvent(m_hMessageEvent);
            }
        }


        // A message has been received or a timeout has occurred.  We check
        // the queue in the latter case to insure against loosing messages
        // which were pending the completion of a device connection (aka
        // Network connection).  Let's read off all messages which may be
        // on the list and dispatch them for processing.
        CMessage *poMessage = GetFirstEntry();
        while(poMessage)
        {
            // Dispatch the message to the user defined processing method
            if(ProcessMessage(poMessage))
            {
                RemoveEntry(poMessage);
                delete poMessage;
                poMessage = NULL;

            }

            // Remove the next message from the list
            poMessage = GetNextEntry();
        }

    }

    // Terminate the Message Thread
    TerminateMessageThread();

}
CEmTubePlaylistEntry* CEmTubePlaylist::RemoveEntry( CEmTubePlaylistEntry* aEntry )
	{
	TInt idx = iEntries.Find( aEntry );
	return RemoveEntry( idx );
	}
Beispiel #26
0
void operator delete(void*ptr,const char * file, int line)
{
    RemoveEntry(ptr);
    free(ptr);
}
List<REG_ENTRY> *RegistryAnalyser::GetNextEntry()
{
	fsl_osal_char symbol;
	efsl_osal_bool bSkip = E_FSL_OSAL_FALSE;
	fsl_osal_char symbolBuffer[ITEM_VALUE_LEN] = {0}, *pStrSeg;
	efsl_osal_bool EntryFounded = E_FSL_OSAL_FALSE;
	fsl_osal_s32 symbolCnt = 0;
	efsl_osal_return_type_t ret;
	REG_ENTRY *pRegEntry;

	if (pfile == NULL)
	{
		LOG_ERROR("No file to read.\n");
		return &RegList;
	}


	/** Remove previous entry */
	RemoveEntry();
	
	while (BufferDataLen - UseOffset > 0 || FileReadEnd == E_FSL_OSAL_FALSE)
	{
		if (BufferDataLen - UseOffset == 0)
		{
			ret = fsl_osal_fread(readBuffer, FILE_READ_SIZE, pfile, &BufferDataLen);
			if (ret != E_FSL_OSAL_SUCCESS && ret != E_FSL_OSAL_EOF)
			{
				LOG_ERROR("file read error.");
				return &RegList;
			}

			if (BufferDataLen < FILE_READ_SIZE)
			{
				FileReadEnd = E_FSL_OSAL_TRUE;
			}

			UseOffset = 0;
		}
		
		symbol = readBuffer[UseOffset];
		UseOffset ++;

		if (bSkip == E_FSL_OSAL_TRUE)
		{
			if (symbol == '\n')
			{
				bSkip = E_FSL_OSAL_FALSE;
			}
		}
		else
		{
			if (symbol == '#')
			{
				bSkip = E_FSL_OSAL_TRUE;
			}
			else if (symbol == '\t'
					|| symbol == ' '
					|| symbol == '\n'
					|| symbol == '\r')
			{
			}
			else if (symbol == '@')
			{
				EntryFounded = E_FSL_OSAL_TRUE;
			}
			else if (symbol == '$')
			{
				break;
			}
			else if (symbol == ';')
			{
				fsl_osal_char *pLast = NULL;
				if (symbolCnt != 0 && ((pStrSeg = fsl_osal_strtok_r(symbolBuffer, "=", &pLast)) != NULL))
				{
					pRegEntry = FSL_NEW(REG_ENTRY, ());
					fsl_osal_memset(pRegEntry, 0, sizeof(REG_ENTRY));
					fsl_osal_strcpy(pRegEntry->name, pStrSeg);
					pStrSeg = fsl_osal_strtok_r(NULL, "=", &pLast);
					fsl_osal_strcpy(pRegEntry->value, pStrSeg);
					fsl_osal_memset(symbolBuffer, 0, ITEM_VALUE_LEN);
					symbolCnt = 0;
					RegList.Add(pRegEntry);
				}
			}
			else
			{
				if (EntryFounded == E_FSL_OSAL_TRUE)
Beispiel #28
0
// destructor
VirtualDir::~VirtualDir()
{
	while (VirtualDirEntry* entry = GetFirstEntry())
		RemoveEntry(entry->GetName());
}
Beispiel #29
0
// Clean up the cache to eliminate expired entries and if neccessary
// delete other entries to remain within the allocated size
VXIcacheResult SBcacheManager::Cleanup (bool forcedCleanup, 
    const SBcacheKey& writingKey)
{
  VXIcacheResult rc = VXIcache_RESULT_SUCCESS;

  if (_curSizeBytes.Get() <= _maxSizeBytes)
    return rc;

  // Log to Mgr and Cleanup logs, and emit an warning the first time
  // cleanup is entered so integrations know if they're filling it too
  // rapidly.
  Diag (SBCACHE_MGR_TAGID, L"Cleanup",
	L"cleanup starting: %lu bytes in cache, %lu allocation",
	_curSizeBytes.Get( ), _maxSizeBytes);
  Diag (SBCACHE_CLEANUP_TAGID, L"Cleanup",
	L"cleanup starting: %lu bytes in cache, %lu allocation",
	_curSizeBytes.Get( ), _maxSizeBytes);
  { static int once = 0;
    if (once == 0) { 
      once = 1;
      Error(302, L"%s%s", L"Cleanup", L"One-time notification: Disk cache "
          L"filled to maximum for first time, performing cleanup.");
    } 
  }

  int bytesToExpire = _curSizeBytes.Get() - _lowWaterBytes;
  time_t now = time(0);
  SBcacheEntryTable::iterator vi;
  SBcacheEntryList::iterator li;
  SBcacheEntryList expiredEntries;
  VXIulong totalBytesFreed = 0;
  time_t oldestAccessed = now;
  int entriesFreed = 0;

  // Lock cache and transfer enough entries from the cache to our temporary
  // list to get us below the cache low water mark.
  // 
  if ( _entryTableMutex.Lock( ) != VXItrd_RESULT_SUCCESS ) {
    Error (110, L"%s%s", L"mutex", L"entry table mutex");
    rc = VXIcache_RESULT_SYSTEM_ERROR;
  } else {
    // Copy entries to our temporary list
    for (li = _entryLRUList.begin(); li != _entryLRUList.end(); ++li) {
      if (bytesToExpire <= 0) break;
      int entrySize = (*li).GetSizeBytes(true);
      if ((*li).GetKey() != writingKey && 
          0 < entrySize &&
          (*li).IsExpired(now, &oldestAccessed)) {
        expiredEntries.push_back(*li);
        totalBytesFreed += entrySize;
        bytesToExpire -= entrySize;
        entriesFreed++;
      }
    }

    // Remove them from cache
    for (li = expiredEntries.begin(); li != expiredEntries.end(); ++li)
      RemoveEntry(*li);

    if ( _entryTableMutex.Unlock( ) != VXItrd_RESULT_SUCCESS ) {
      Error (111, L"%s%s", L"mutex", L"entry table mutex");
      rc = VXIcache_RESULT_SYSTEM_ERROR;
    }
  }

  // Now that we're outside the cache lock, actually remove all the
  // entries by removing the last reference to them in our list.
  expiredEntries.erase(expiredEntries.begin(), expiredEntries.end());
  _curSizeBytes.Decrement(totalBytesFreed);

  // Log prior to setting the next cleanup time to ensure we log our
  // completion prior to another cleanup starting
  Diag (SBCACHE_MGR_TAGID, L"Cleanup",
      L"exiting: rc = %d, released %u entries, %lu bytes, %lu bytes in cache",
	rc, entriesFreed, totalBytesFreed, _curSizeBytes.Get( ));
  Diag (SBCACHE_CLEANUP_TAGID, L"Cleanup",
      L"exiting: rc = %d, released %u entries, %lu bytes, %lu bytes in cache",
	rc, entriesFreed, totalBytesFreed, _curSizeBytes.Get( ));

  return rc;
}
Beispiel #30
0
void operator delete(void *ptr)
{
    RemoveEntry(ptr);
    free(ptr);
}