Bump liberty
This commit is contained in:
parent
f070523085
commit
6db40c4503
47
kike.c
47
kike.c
|
@ -3783,51 +3783,6 @@ irc_initialize_server_name (struct server_context *ctx, struct error **e)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
|
||||||
lock_pid_file (const char *path, struct error **e)
|
|
||||||
{
|
|
||||||
// When using XDG_RUNTIME_DIR, the file needs to either have its
|
|
||||||
// access time bumped every 6 hours, or have the sticky bit set
|
|
||||||
int fd = open (path, O_RDWR | O_CREAT,
|
|
||||||
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH /* 644 */ | S_ISVTX /* sticky */);
|
|
||||||
if (fd < 0)
|
|
||||||
{
|
|
||||||
error_set (e, "can't open `%s': %s", path, strerror (errno));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct flock lock =
|
|
||||||
{
|
|
||||||
.l_type = F_WRLCK,
|
|
||||||
.l_start = 0,
|
|
||||||
.l_whence = SEEK_SET,
|
|
||||||
.l_len = 0,
|
|
||||||
};
|
|
||||||
if (fcntl (fd, F_SETLK, &lock))
|
|
||||||
{
|
|
||||||
error_set (e, "can't lock `%s': %s", path, strerror (errno));
|
|
||||||
xclose (fd);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct str pid;
|
|
||||||
str_init (&pid);
|
|
||||||
str_append_printf (&pid, "%ld", (long) getpid ());
|
|
||||||
|
|
||||||
if (ftruncate (fd, 0)
|
|
||||||
|| write (fd, pid.str, pid.len) != (ssize_t) pid.len)
|
|
||||||
{
|
|
||||||
error_set (e, "can't write to `%s': %s", path, strerror (errno));
|
|
||||||
xclose (fd);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
str_free (&pid);
|
|
||||||
|
|
||||||
// Intentionally not closing the file descriptor; it must stay alive
|
|
||||||
// for the entire life of the application
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
irc_lock_pid_file (struct server_context *ctx, struct error **e)
|
irc_lock_pid_file (struct server_context *ctx, struct error **e)
|
||||||
{
|
{
|
||||||
|
@ -3836,7 +3791,7 @@ irc_lock_pid_file (struct server_context *ctx, struct error **e)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
char *resolved = resolve_filename (path, resolve_relative_runtime_filename);
|
char *resolved = resolve_filename (path, resolve_relative_runtime_filename);
|
||||||
bool result = lock_pid_file (resolved, e);
|
bool result = lock_pid_file (resolved, e) != -1;
|
||||||
free (resolved);
|
free (resolved);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
2
liberty
2
liberty
|
@ -1 +1 @@
|
||||||
Subproject commit 8a9a28231bba6334c383dca59f7eccd1e5075693
|
Subproject commit f213a76ad494efe150a786b195a744e4b87c5ca9
|
Loading…
Reference in New Issue