Commit e4b7a113 authored by Max Kellermann's avatar Max Kellermann

database, ...: remove EINTR checks after stdio calls

MPD doesn't have child processes anymore, and thus we're not expecting to receive SIGCHLD very often. Since hard disk access isn't interrupted by signals anyway, we don't need those excessive checks.
parent 7820ebb8
...@@ -255,11 +255,11 @@ db_save(void) ...@@ -255,11 +255,11 @@ db_save(void)
if (ferror(fp)) { if (ferror(fp)) {
g_warning("Failed to write to database file: %s", g_warning("Failed to write to database file: %s",
strerror(errno)); strerror(errno));
while (fclose(fp) && errno == EINTR); fclose(fp);
return false; return false;
} }
while (fclose(fp) && errno == EINTR); fclose(fp);
if (stat(database_path, &st) == 0) if (stat(database_path, &st) == 0)
database_mtime = st.st_mtime; database_mtime = st.st_mtime;
...@@ -282,7 +282,7 @@ db_load(GError **error) ...@@ -282,7 +282,7 @@ db_load(GError **error)
assert(database_path != NULL); assert(database_path != NULL);
assert(music_root != NULL); assert(music_root != NULL);
while (!(fp = fopen(database_path, "r")) && errno == EINTR) ; fp = fopen(database_path, "r");
if (fp == NULL) { if (fp == NULL) {
g_set_error(error, db_quark(), errno, g_set_error(error, db_quark(), errno,
"Failed to open database file \"%s\": %s", "Failed to open database file \"%s\": %s",
...@@ -383,7 +383,7 @@ db_load(GError **error) ...@@ -383,7 +383,7 @@ db_load(GError **error)
success = directory_load(fp, music_root, buffer, error); success = directory_load(fp, music_root, buffer, error);
g_string_free(buffer, true); g_string_free(buffer, true);
while (fclose(fp) && errno == EINTR) ; fclose(fp);
if (!success) if (!success)
return false; return false;
......
...@@ -202,7 +202,7 @@ static void ...@@ -202,7 +202,7 @@ static void
oss_close(struct oss_data *od) oss_close(struct oss_data *od)
{ {
if (od->fd >= 0) if (od->fd >= 0)
while (close(od->fd) && errno == EINTR) ; close(od->fd);
od->fd = -1; od->fd = -1;
} }
......
...@@ -66,7 +66,7 @@ void initSigHandlers(void) ...@@ -66,7 +66,7 @@ void initSigHandlers(void)
sa.sa_flags = 0; sa.sa_flags = 0;
sigemptyset(&sa.sa_mask); sigemptyset(&sa.sa_mask);
sa.sa_handler = SIG_IGN; sa.sa_handler = SIG_IGN;
while (sigaction(SIGPIPE, &sa, NULL) < 0 && errno == EINTR) ; x_sigaction(SIGPIPE, &sa);
sa.sa_handler = exit_signal_handler; sa.sa_handler = exit_signal_handler;
x_sigaction(SIGINT, &sa); x_sigaction(SIGINT, &sa);
......
...@@ -65,7 +65,7 @@ state_file_write(void) ...@@ -65,7 +65,7 @@ state_file_write(void)
audio_output_state_save(fp); audio_output_state_save(fp);
playlist_state_save(fp, &g_playlist); playlist_state_save(fp, &g_playlist);
while(fclose(fp) && errno == EINTR) /* nothing */; fclose(fp);
prev_volume_version = sw_volume_state_get_hash(); prev_volume_version = sw_volume_state_get_hash();
prev_output_version = audio_output_state_get_version(); prev_output_version = audio_output_state_get_version();
...@@ -100,7 +100,7 @@ state_file_read(void) ...@@ -100,7 +100,7 @@ state_file_read(void)
g_warning("Unrecognized line in state file: %s", line); g_warning("Unrecognized line in state file: %s", line);
} }
while(fclose(fp) && errno == EINTR) /* nothing */; fclose(fp);
prev_volume_version = sw_volume_state_get_hash(); prev_volume_version = sw_volume_state_get_hash();
prev_output_version = audio_output_state_get_version(); prev_output_version = audio_output_state_get_version();
......
...@@ -160,7 +160,7 @@ spl_save(GPtrArray *list, const char *utf8path) ...@@ -160,7 +160,7 @@ spl_save(GPtrArray *list, const char *utf8path)
if (path_fs == NULL) if (path_fs == NULL)
return PLAYLIST_RESULT_BAD_NAME; return PLAYLIST_RESULT_BAD_NAME;
while (!(file = fopen(path_fs, "w")) && errno == EINTR); file = fopen(path_fs, "w");
g_free(path_fs); g_free(path_fs);
if (file == NULL) if (file == NULL)
return PLAYLIST_RESULT_ERRNO; return PLAYLIST_RESULT_ERRNO;
...@@ -170,7 +170,7 @@ spl_save(GPtrArray *list, const char *utf8path) ...@@ -170,7 +170,7 @@ spl_save(GPtrArray *list, const char *utf8path)
playlist_print_uri(file, uri); playlist_print_uri(file, uri);
} }
while (fclose(file) != 0 && errno == EINTR); fclose(file);
return PLAYLIST_RESULT_SUCCESS; return PLAYLIST_RESULT_SUCCESS;
} }
...@@ -189,7 +189,7 @@ spl_load(const char *utf8path) ...@@ -189,7 +189,7 @@ spl_load(const char *utf8path)
if (path_fs == NULL) if (path_fs == NULL)
return NULL; return NULL;
while (!(file = fopen(path_fs, "r")) && errno == EINTR); file = fopen(path_fs, "r");
g_free(path_fs); g_free(path_fs);
if (file == NULL) if (file == NULL)
return NULL; return NULL;
...@@ -227,7 +227,7 @@ spl_load(const char *utf8path) ...@@ -227,7 +227,7 @@ spl_load(const char *utf8path)
break; break;
} }
while (fclose(file) && errno == EINTR); fclose(file);
return list; return list;
} }
...@@ -313,12 +313,12 @@ spl_clear(const char *utf8path) ...@@ -313,12 +313,12 @@ spl_clear(const char *utf8path)
if (path_fs == NULL) if (path_fs == NULL)
return PLAYLIST_RESULT_BAD_NAME; return PLAYLIST_RESULT_BAD_NAME;
while (!(file = fopen(path_fs, "w")) && errno == EINTR); file = fopen(path_fs, "w");
g_free(path_fs); g_free(path_fs);
if (file == NULL) if (file == NULL)
return PLAYLIST_RESULT_ERRNO; return PLAYLIST_RESULT_ERRNO;
while (fclose(file) != 0 && errno == EINTR); fclose(file);
idle_add(IDLE_STORED_PLAYLIST); idle_add(IDLE_STORED_PLAYLIST);
return PLAYLIST_RESULT_SUCCESS; return PLAYLIST_RESULT_SUCCESS;
...@@ -393,26 +393,26 @@ spl_append_song(const char *utf8path, struct song *song) ...@@ -393,26 +393,26 @@ spl_append_song(const char *utf8path, struct song *song)
if (path_fs == NULL) if (path_fs == NULL)
return PLAYLIST_RESULT_BAD_NAME; return PLAYLIST_RESULT_BAD_NAME;
while (!(file = fopen(path_fs, "a")) && errno == EINTR); file = fopen(path_fs, "a");
g_free(path_fs); g_free(path_fs);
if (file == NULL) if (file == NULL)
return PLAYLIST_RESULT_ERRNO; return PLAYLIST_RESULT_ERRNO;
if (fstat(fileno(file), &st) < 0) { if (fstat(fileno(file), &st) < 0) {
int save_errno = errno; int save_errno = errno;
while (fclose(file) != 0 && errno == EINTR); fclose(file);
errno = save_errno; errno = save_errno;
return PLAYLIST_RESULT_ERRNO; return PLAYLIST_RESULT_ERRNO;
} }
if (st.st_size / (MPD_PATH_MAX + 1) >= (off_t)playlist_max_length) { if (st.st_size / (MPD_PATH_MAX + 1) >= (off_t)playlist_max_length) {
while (fclose(file) != 0 && errno == EINTR); fclose(file);
return PLAYLIST_RESULT_TOO_LARGE; return PLAYLIST_RESULT_TOO_LARGE;
} }
playlist_print_song(file, song); playlist_print_song(file, song);
while (fclose(file) != 0 && errno == EINTR); fclose(file);
idle_add(IDLE_STORED_PLAYLIST); idle_add(IDLE_STORED_PLAYLIST);
return PLAYLIST_RESULT_SUCCESS; return PLAYLIST_RESULT_SUCCESS;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment