Skip to content

A possible locking issue #885

@true-ryan

Description

@true-ryan

Hi, should the lock be released after Line 863 to protect l->dropped++ from races?

memcached/logger.c

Lines 858 to 865 in 894e4c1

pthread_mutex_lock(&l->mutex);
/* Request a maximum length of data to write to */
e = (logentry *) bipbuf_request(buf, (sizeof(logentry) + reqlen));
if (e == NULL) {
pthread_mutex_unlock(&l->mutex);
l->dropped++;
return LOGGER_RET_NOSPACE;
}

like this way

 pthread_mutex_lock(&l->mutex); 
 /* Request a maximum length of data to write to */ 
 e = (logentry *) bipbuf_request(buf, (sizeof(logentry) + reqlen)); 
 if (e == NULL) { 
     l->dropped++;
     pthread_mutex_unlock(&l->mutex); 
     return LOGGER_RET_NOSPACE; 
 } 

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions