Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
mx_flock: export mx_flock_free() to free without releasing lock
  • Loading branch information
mariux committed Nov 3, 2015
1 parent 1291fc5 commit acc1eb6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
12 changes: 7 additions & 5 deletions mx_flock.c
Expand Up @@ -58,11 +58,7 @@ static inline void _flock_free(struct mx_flock *lock)
if (!lock)
return;

if (lock->fname)
mx_free_null(lock->fname);

if (lock->fd >= 0)
_flock_close(lock);
mx_free_null(lock->fname);

free(lock);
}
Expand Down Expand Up @@ -112,6 +108,7 @@ struct mx_flock *mx_flock(int operation, char *fmt, ...)
if (errno == EWOULDBLOCK)
return lock;
mx_log_err("flock(): %m");
_flock_close(lock);
_flock_free(lock);
return NULL;
}
Expand Down Expand Up @@ -155,3 +152,8 @@ int mx_funlock(struct mx_flock *lock)

return res;
}

void mx_flock_free(struct mx_flock *lock)
{
_flock_free(lock);
}
1 change: 1 addition & 0 deletions mx_flock.h
Expand Up @@ -10,5 +10,6 @@ struct mx_flock {

struct mx_flock *mx_flock(int operation, char *fmt, ...);
int mx_funlock(struct mx_flock *lock);
void mx_flock_free(struct mx_flock *lock);

#endif

0 comments on commit acc1eb6

Please sign in to comment.