Folge dem Video um zu sehen, wie unsere Website als Web-App auf dem Startbildschirm installiert werden kann.
Anmerkung: Diese Funktion ist in einigen Browsern möglicherweise nicht verfügbar.
Ah, OK. Das war mir neu. Allerdings würde ich bezweifeln das der Quellcode einfach so beliebig angepasst und neu kompiliert werden kann. Außerdem vermute ich mal, das die Fehlermeldung nicht aus dem MFC Code kommt sondern sich eher aus der darunterliegenden C Bibliothek.Hi,
das war mein ernst. Die MFC liegt doch als source - code im Verzeichnis
C:\Programme\Microsoft Visual Studio\VC98\MFC\SRC.
Das klingt ziemlich unwahrscheinlich. Hast du dafür irgendwelche Anhaltspunkte gefunden ?Der Fehler den ich habe, den kriege ich nicht raus.
Das ganze hängt mit den SNMP - Traps zusammen (Siehe meinen vorletzten Beitrag).
Es entstehen Speicher - Leaks, die ich nicht herausbekomme und beim beenden des Programms enteht die hässliche Fehlermeldung
DAMAGE after Ignore block ...
Ich würde den Fehler gerne in meinem code finden und beseitigen, ich vermute aber,
daß zumindest einer der libs snmpapi.lib oder mgmtapi.lib fehlerbehaftet sind.
void __cdecl _free_dbg_lk(
#else /* _MT */
_CRTIMP void __cdecl _free_dbg(
#endif /* _MT */
void * pUserData,
int nBlockUse
)
{
_CrtMemBlockHeader * pHead;
/* verify heap before freeing */
if (_crtDbgFlag & _CRTDBG_CHECK_ALWAYS_DF)
_ASSERTE(_CrtCheckMemory());
if (pUserData == NULL)
return;
/* forced failure */
if (!(*_pfnAllocHook)(_HOOK_FREE, pUserData, 0, nBlockUse, 0L, NULL, 0))
{
_RPT0(_CRT_WARN, "Client hook free failure.\n");
return;
}
/*
* If this ASSERT fails, a bad pointer has been passed in. It may be
* totally bogus, or it may have been allocated from another heap.
* The pointer MUST come from the 'local' heap.
*/
_ASSERTE(_CrtIsValidHeapPointer(pUserData));
/* get a pointer to memory block header */
pHead = pHdr(pUserData);
/* verify block type */
_ASSERTE(_BLOCK_TYPE_IS_VALID(pHead->nBlockUse));
/* if we didn't already check entire heap, at least check this object */
if ( 0 && !(_crtDbgFlag & _CRTDBG_CHECK_ALWAYS_DF))
{
/* check no-mans-land gaps */
if (!CheckBytes(pHead->gap, _bNoMansLandFill, nNoMansLandSize))
_RPT3(_CRT_ERROR, "DAMAGE: before %hs block (#%d) at 0x%08X.\n",
szBlockUseName[_BLOCK_TYPE(pHead->nBlockUse)],
pHead->lRequest,
(BYTE *) pbData(pHead));
if (!CheckBytes(pbData(pHead) + pHead->nDataSize, _bNoMansLandFill, nNoMansLandSize))
_RPT3(_CRT_ERROR, "DAMAGE: after %hs block (#%d) at 0x%08X.\n",
szBlockUseName[_BLOCK_TYPE(pHead->nBlockUse)],
pHead->lRequest,
(BYTE *) pbData(pHead));
}
if (pHead->nBlockUse == _IGNORE_BLOCK)
{
_ASSERTE(pHead->nLine == IGNORE_LINE && pHead->lRequest == IGNORE_REQ);
/* fill the entire block including header with dead-land-fill */
memset(pHead, _bDeadLandFill,
sizeof(_CrtMemBlockHeader) + pHead->nDataSize + nNoMansLandSize);
_free_base(pHead);
return;
}
/* CRT blocks can be freed as NORMAL blocks */
if (pHead->nBlockUse == _CRT_BLOCK && nBlockUse == _NORMAL_BLOCK)
nBlockUse = _CRT_BLOCK;
/* Error if freeing incorrect memory type */
_ASSERTE(pHead->nBlockUse == nBlockUse);
/* keep track of total amount of memory allocated */
_lCurAlloc -= pHead->nDataSize;
/* optionally reclaim memory */
if (!(_crtDbgFlag & _CRTDBG_DELAY_FREE_MEM_DF))
{
/* remove from the linked list */
if (pHead->pBlockHeaderNext)
{
pHead->pBlockHeaderNext->pBlockHeaderPrev = pHead->pBlockHeaderPrev;
}
else
{
_ASSERTE(_pLastBlock == pHead);
_pLastBlock = pHead->pBlockHeaderPrev;
}
if (pHead->pBlockHeaderPrev)
{
pHead->pBlockHeaderPrev->pBlockHeaderNext = pHead->pBlockHeaderNext;
}
else
{
_ASSERTE(_pFirstBlock == pHead);
_pFirstBlock = pHead->pBlockHeaderNext;
}
/* fill the entire block including header with dead-land-fill */
memset(pHead, _bDeadLandFill,
sizeof(_CrtMemBlockHeader) + pHead->nDataSize + nNoMansLandSize);
_free_base(pHead);
}
else
{
pHead->nBlockUse = _FREE_BLOCK;
/* keep memory around as dead space */
memset(pbData(pHead), _bDeadLandFill, pHead->nDataSize);
}
}
UINT CBpSnmpThreadStatusBar::requestSNMP()
{
HANDLE hTrap = 0;
bool bTrap = false;
map<CString, CBpTrapInfo> trapinfo;
CStringArray csaIps;
CStringArray csaSystem;
genIpArray(csaIps);
genSystemnameArray(csaSystem);
CBpTrapInfo ti;
ti.m_nLastTrap = time(0);
ti.m_nErrorKathegorie = 0;
for ( int i = 0, l = csaIps.GetSize(); i < l; i++ )
{
ti.m_csSystem = csaSystem[i];
trapinfo.insert(map<CString, CBpTrapInfo>::value_type(csaIps[i], ti));
}
while (true)
{
if ( bTrap || SnmpMgrTrapListen( &hTrap ) )
{
bTrap = true;
DWORD dwResult = WaitForSingleObject( hTrap, 10000 );
if ( dwResult != WAIT_FAILED && dwResult != WAIT_TIMEOUT )
{
RFC1157VarBindList TrapVarBinds;
//TrapVarBinds.list = new RFC1157VarBind;
if ( 0 == ( TrapVarBinds.list = (RFC1157VarBind *) SnmpUtilMemAlloc(sizeof( RFC1157VarBind ) ) ) )
{
AfxMessageBox("FATAL:No memory to alloc snmp vars");
break;
}
memset(TrapVarBinds.list, 0, sizeof(RFC1157VarBind));
bool bFatal = false;
AsnObjectIdentifier TrapEnterprise;
AsnIPAddress TrapIpAddress;
AsnIPAddress TrapSourceAddress;
AsnInteger TrapGeneric;
AsnInteger TrapSpecific;
AsnOctetString TrapCommunity;
AsnTimeticks TrapTimeStamp;
while ( SnmpMgrGetTrapEx( &TrapEnterprise,
&TrapIpAddress,
&TrapSourceAddress,
&TrapGeneric,
&TrapSpecific,
&TrapCommunity,
&TrapTimeStamp,
&TrapVarBinds ) )
{
if ( TrapIpAddress.dynamic )
{
SnmpUtilMemFree( TrapIpAddress.stream );
//delete TrapIpAddress.stream;
TrapIpAddress.length = 0;
TrapIpAddress.stream = 0;
}
SnmpUtilOidFree( &TrapEnterprise );
//delete TrapEnterprise.ids;
TrapEnterprise.ids = 0;
TrapEnterprise.idLength = 0;
CString csIp = "";
CString csError = "";
CString csTime = "";
convTrapVars(csIp, csError, csTime, &TrapVarBinds);
/*
SnmpUtilVarBindListFree( &TrapVarBinds );
TrapVarBinds.list = 0;
TrapVarBinds.len = 0;
*/
if ( ! csIp.IsEmpty() &&
! csError.IsEmpty() &&
! csTime.IsEmpty() )
{
bool bFound = false;
for ( i = 0, l = csaIps.GetSize(); i < l; i++ )
if ( csIp == csaIps[i] )
{
bFound = true;
break;
}
int nMaxErrorKathegorie = 0;
int nErrorKathegorie = 0;
if ( bFound )
{
trapinfo[csIp].m_nLastTrap = time(0);
trapinfo[csIp].m_nErrorKathegorie = 0;
trapinfo[csIp].m_nCount++;
while ( ! csError.IsEmpty() )
{
CString csErrorNumber;
CString csErrorKathegorie;
CString csErrorText;
firstString(csErrorNumber, csError);
firstString(csErrorKathegorie, csError);
firstString(csErrorText, csError);
nErrorKathegorie = atoi(csErrorKathegorie);
if ( nMaxErrorKathegorie < nErrorKathegorie )
nMaxErrorKathegorie = nErrorKathegorie;
q.push(CBpErrorInfo(atoi(csErrorKathegorie),
trapinfo[csIp].m_csSystem,
csErrorText,
csTime));
if ( q.size() > SNMPMAXTRAPS )
q.pop();
}
trapinfo[csIp].m_nErrorKathegorie = nMaxErrorKathegorie;
}
}
bFatal = false;
for ( i = 0, l = csaIps.GetSize(); i < l; i++ )
{
if ( time(0) - trapinfo[csaIps[i]].m_nLastTrap > SNMPTRAPDELAYTIME )
{
CTime t(CTime::GetCurrentTime());
CString csTime = t.Format("%Y-%m-%d %H:%M:%S");
bFatal = true;
q.push(CBpErrorInfo(4,
trapinfo[csIp].m_csSystem,
" FATAL SYSTEM NOT REACHABLE ",
csTime));
if ( q.size() > SNMPMAXTRAPS )
q.pop();
}
}
}
//delete TrapVarBinds.list;
SnmpUtilVarBindListFree( &TrapVarBinds );
TrapVarBinds.list = 0;
TrapVarBinds.len = 0;
if ( ! bFatal )
{
int nMaxErrorKathegorie = 0;
for ( i = 0, l = csaIps.GetSize(); i < l; i++ )
if ( trapinfo[csaIps[i]].m_nErrorKathegorie > nMaxErrorKathegorie )
nMaxErrorKathegorie = trapinfo[csaIps[i]].m_nErrorKathegorie;
setState(nMaxErrorKathegorie);
}
else
setState(4);
}
else
{
bool bFatal = false;
for ( i = 0, l = csaIps.GetSize(); i < l; i++ )
{
if ( time(0) - trapinfo[csaIps[i]].m_nLastTrap > SNMPTRAPDELAYTIME )
{
CTime t(CTime::GetCurrentTime());
CString csTime = t.Format("%Y-%m-%d %H:%M:%S");
bFatal = true;
q.push(CBpErrorInfo(4,
trapinfo[csaIps[i]].m_csSystem,
" FATAL SYSTEM NOT REACHABLE ",
csTime));
if ( q.size() > SNMPMAXTRAPS )
q.pop();
}
}
if ( bFatal )
setState(4);
}
ResetEvent( hTrap );
}
if ( WaitForSingleObject(m_hStopThread, 0) == WAIT_OBJECT_0 )
{
SetEvent(m_hThreadStopped);
break;
}
}
return 0;
}