Poznámka
Na prístup k tejto stránke sa vyžaduje oprávnenie. Môžete sa skúsiť prihlásiť alebo zmeniť adresáre.
Na prístup k tejto stránke sa vyžaduje oprávnenie. Môžete skúsiť zmeniť adresáre.
Failing to release lock 'lock' in function 'func'.
Remarks
Enforcement of syntactically scoped lock acquire and lock release pairs in C/C++ programs isn't performed by the language. A function may introduce a locking side effect by making an observable modification to the concurrency state. For example, a lock wrapper function increments the number of lock acquisitions, or lock count, for a given lock.
You can annotate a function that has a side effect from a lock acquire or lock release by using _Acquires_lock_ or _Releases_lock_, respectively. Without such annotations, a function is expected not to change any lock count after it returns. If acquires and releases aren't balanced, they're considered to be orphaned. Warning C26115 is issued when a function introduces an orphaned lock.
Example
The following example generates warning C26115 because there's an orphaned lock in a function that isn't annotated with _Acquires_lock_.
typedef struct _DATA
{
CRITICAL_SECTION cs;
} DATA;
void FailToReleaseLock(int flag, DATA* p)
{
EnterCriticalSection(&p->cs);
if (flag)
return; // Warning C26115
LeaveCriticalSection(&p->cs);
}