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.
This commit is contained in:
Max Kellermann 2010-07-25 11:09:13 +02:00
parent 7820ebb82e
commit e4b7a113fd
5 changed files with 18 additions and 18 deletions

View File

@ -255,11 +255,11 @@ db_save(void)
if (ferror(fp)) {
g_warning("Failed to write to database file: %s",
strerror(errno));
while (fclose(fp) && errno == EINTR);
fclose(fp);
return false;
}
while (fclose(fp) && errno == EINTR);
fclose(fp);
if (stat(database_path, &st) == 0)
database_mtime = st.st_mtime;
@ -282,7 +282,7 @@ db_load(GError **error)
assert(database_path != NULL);
assert(music_root != NULL);
while (!(fp = fopen(database_path, "r")) && errno == EINTR) ;
fp = fopen(database_path, "r");
if (fp == NULL) {
g_set_error(error, db_quark(), errno,
"Failed to open database file \"%s\": %s",
@ -383,7 +383,7 @@ db_load(GError **error)
success = directory_load(fp, music_root, buffer, error);
g_string_free(buffer, true);
while (fclose(fp) && errno == EINTR) ;
fclose(fp);
if (!success)
return false;

View File

@ -202,7 +202,7 @@ static void
oss_close(struct oss_data *od)
{
if (od->fd >= 0)
while (close(od->fd) && errno == EINTR) ;
close(od->fd);
od->fd = -1;
}

View File

@ -66,7 +66,7 @@ void initSigHandlers(void)
sa.sa_flags = 0;
sigemptyset(&sa.sa_mask);
sa.sa_handler = SIG_IGN;
while (sigaction(SIGPIPE, &sa, NULL) < 0 && errno == EINTR) ;
x_sigaction(SIGPIPE, &sa);
sa.sa_handler = exit_signal_handler;
x_sigaction(SIGINT, &sa);

View File

@ -65,7 +65,7 @@ state_file_write(void)
audio_output_state_save(fp);
playlist_state_save(fp, &g_playlist);
while(fclose(fp) && errno == EINTR) /* nothing */;
fclose(fp);
prev_volume_version = sw_volume_state_get_hash();
prev_output_version = audio_output_state_get_version();
@ -100,7 +100,7 @@ state_file_read(void)
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_output_version = audio_output_state_get_version();

View File

@ -160,7 +160,7 @@ spl_save(GPtrArray *list, const char *utf8path)
if (path_fs == NULL)
return PLAYLIST_RESULT_BAD_NAME;
while (!(file = fopen(path_fs, "w")) && errno == EINTR);
file = fopen(path_fs, "w");
g_free(path_fs);
if (file == NULL)
return PLAYLIST_RESULT_ERRNO;
@ -170,7 +170,7 @@ spl_save(GPtrArray *list, const char *utf8path)
playlist_print_uri(file, uri);
}
while (fclose(file) != 0 && errno == EINTR);
fclose(file);
return PLAYLIST_RESULT_SUCCESS;
}
@ -189,7 +189,7 @@ spl_load(const char *utf8path)
if (path_fs == NULL)
return NULL;
while (!(file = fopen(path_fs, "r")) && errno == EINTR);
file = fopen(path_fs, "r");
g_free(path_fs);
if (file == NULL)
return NULL;
@ -227,7 +227,7 @@ spl_load(const char *utf8path)
break;
}
while (fclose(file) && errno == EINTR);
fclose(file);
return list;
}
@ -313,12 +313,12 @@ spl_clear(const char *utf8path)
if (path_fs == NULL)
return PLAYLIST_RESULT_BAD_NAME;
while (!(file = fopen(path_fs, "w")) && errno == EINTR);
file = fopen(path_fs, "w");
g_free(path_fs);
if (file == NULL)
return PLAYLIST_RESULT_ERRNO;
while (fclose(file) != 0 && errno == EINTR);
fclose(file);
idle_add(IDLE_STORED_PLAYLIST);
return PLAYLIST_RESULT_SUCCESS;
@ -393,26 +393,26 @@ spl_append_song(const char *utf8path, struct song *song)
if (path_fs == NULL)
return PLAYLIST_RESULT_BAD_NAME;
while (!(file = fopen(path_fs, "a")) && errno == EINTR);
file = fopen(path_fs, "a");
g_free(path_fs);
if (file == NULL)
return PLAYLIST_RESULT_ERRNO;
if (fstat(fileno(file), &st) < 0) {
int save_errno = errno;
while (fclose(file) != 0 && errno == EINTR);
fclose(file);
errno = save_errno;
return PLAYLIST_RESULT_ERRNO;
}
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;
}
playlist_print_song(file, song);
while (fclose(file) != 0 && errno == EINTR);
fclose(file);
idle_add(IDLE_STORED_PLAYLIST);
return PLAYLIST_RESULT_SUCCESS;