Skip to content

Commit

Permalink
Merge pull request #112 from mariux64/unlock-without-unlink
Browse files Browse the repository at this point in the history
Unlock without unlink
  • Loading branch information
donald authored Sep 17, 2021
2 parents 402c046 + b8fd11a commit 7b1c066
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
11 changes: 7 additions & 4 deletions mx_flock.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,19 @@ int mx_funlock(struct mx_flock *lock)
if (res < 0)
mx_log_warning("unlink(): %m");

res = flock(lock->fd, LOCK_UN);
if (res < 0)
mx_log_warning("flock(): %m");

_flock_close(lock);
_flock_free(lock);

return res;
}

/* as above, but don't delete lock file
*/
void mx_funlock_nodelete(struct mx_flock *lock) {
_flock_close(lock);
_flock_free(lock);
}

void mx_flock_free(struct mx_flock *lock)
{
_flock_free(lock);
Expand Down
1 change: 1 addition & 0 deletions mx_flock.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ struct mx_flock {

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

#endif
2 changes: 1 addition & 1 deletion mxqd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,7 @@ unsigned long start_job(struct mxq_group_list *glist)
job->host_pid = getpid();

mx_log_debug("starting reaper process.");
mx_funlock(server->flock);
mx_funlock_nodelete(server->flock);
server->flock = NULL;
mx_mysql_finish(&server->mysql);

Expand Down

0 comments on commit 7b1c066

Please sign in to comment.