forked from external/yambar
module/mpd: check return value of write()
Fixes building with -D_FORTIFY_SOURCE=2
This commit is contained in:
parent
2450cbe7a6
commit
27a47a96ed
1 changed files with 14 additions and 4 deletions
|
@ -65,10 +65,15 @@ destroy(struct module *mod)
|
||||||
struct private *m = mod->private;
|
struct private *m = mod->private;
|
||||||
if (m->refresh_thread_id != 0) {
|
if (m->refresh_thread_id != 0) {
|
||||||
assert(m->refresh_abort_fd != -1);
|
assert(m->refresh_abort_fd != -1);
|
||||||
write(m->refresh_abort_fd, &(uint64_t){1}, sizeof(uint64_t));
|
if (write(m->refresh_abort_fd, &(uint64_t){1}, sizeof(uint64_t))
|
||||||
|
!= sizeof(uint64_t))
|
||||||
|
{
|
||||||
|
LOG_ERRNO("failed to signal abort to refresher thread");
|
||||||
|
} else{
|
||||||
|
int res;
|
||||||
|
thrd_join(m->refresh_thread_id, &res);
|
||||||
|
}
|
||||||
|
|
||||||
int res;
|
|
||||||
thrd_join(m->refresh_thread_id, &res);
|
|
||||||
close(m->refresh_abort_fd);
|
close(m->refresh_abort_fd);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -521,7 +526,12 @@ refresh_in(struct module *mod, long milli_seconds)
|
||||||
|
|
||||||
/* Signal abort to thread */
|
/* Signal abort to thread */
|
||||||
assert(m->refresh_abort_fd != -1);
|
assert(m->refresh_abort_fd != -1);
|
||||||
write(m->refresh_abort_fd, &(uint64_t){1}, sizeof(uint64_t));
|
if (write(m->refresh_abort_fd, &(uint64_t){1}, sizeof(uint64_t))
|
||||||
|
!= sizeof(uint64_t))
|
||||||
|
{
|
||||||
|
LOG_ERRNO("failed to signal abort to refresher thread");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* Wait for it to finish */
|
/* Wait for it to finish */
|
||||||
int res;
|
int res;
|
||||||
|
|
Loading…
Add table
Reference in a new issue