@@ -364,7 +364,7 @@ push_file(WALSegno *xlogfile, const char *archive_status_dir,
364
364
elog (LOG , "Rename \"%s\" to \"%s\"" , wal_file_ready , wal_file_done );
365
365
366
366
/* do not error out, if rename failed */
367
- if (fio_rename (wal_file_ready , wal_file_done , FIO_DB_HOST ) < 0 )
367
+ if (fio_rename (FIO_DB_HOST , wal_file_ready , wal_file_done ) < 0 )
368
368
elog (WARNING , "Cannot rename ready file \"%s\" to \"%s\": %s" ,
369
369
wal_file_ready , wal_file_done , strerror (errno ));
370
370
}
@@ -418,7 +418,7 @@ push_file_internal_uncompressed(const char *wal_file_name, const char *pg_xlog_d
418
418
snprintf (to_fullpath_part , sizeof (to_fullpath_part ), "%s.part" , to_fullpath );
419
419
420
420
/* Grab lock by creating temp file in exclusive mode */
421
- out = fio_open (to_fullpath_part , O_RDWR | O_CREAT | O_EXCL | PG_BINARY , FIO_BACKUP_HOST );
421
+ out = fio_open (FIO_BACKUP_HOST , to_fullpath_part , O_RDWR | O_CREAT | O_EXCL | PG_BINARY );
422
422
if (out < 0 )
423
423
{
424
424
if (errno != EEXIST )
@@ -444,12 +444,12 @@ push_file_internal_uncompressed(const char *wal_file_name, const char *pg_xlog_d
444
444
445
445
while (partial_try_count < archive_timeout )
446
446
{
447
- if (fio_stat (to_fullpath_part , & st , false, FIO_BACKUP_HOST ) < 0 )
447
+ if (fio_stat (FIO_BACKUP_HOST , to_fullpath_part , & st , false) < 0 )
448
448
{
449
449
if (errno == ENOENT )
450
450
{
451
451
//part file is gone, lets try to grab it
452
- out = fio_open (to_fullpath_part , O_RDWR | O_CREAT | O_EXCL | PG_BINARY , FIO_BACKUP_HOST );
452
+ out = fio_open (FIO_BACKUP_HOST , to_fullpath_part , O_RDWR | O_CREAT | O_EXCL | PG_BINARY );
453
453
if (out < 0 )
454
454
{
455
455
if (errno != EEXIST )
@@ -497,10 +497,10 @@ push_file_internal_uncompressed(const char *wal_file_name, const char *pg_xlog_d
497
497
498
498
/* Partial segment is considered stale, so reuse it */
499
499
elog (LOG , "Reusing stale temp WAL file \"%s\"" , to_fullpath_part );
500
- if (fio_remove (to_fullpath_part , false, FIO_BACKUP_HOST ) != 0 )
500
+ if (fio_remove (FIO_BACKUP_HOST , to_fullpath_part , false ) != 0 )
501
501
elog (ERROR , "Cannot remove stale temp WAL file \"%s\": %s" , to_fullpath_part , strerror (errno ));
502
502
503
- out = fio_open (to_fullpath_part , O_RDWR | O_CREAT | O_EXCL | PG_BINARY , FIO_BACKUP_HOST );
503
+ out = fio_open (FIO_BACKUP_HOST , to_fullpath_part , O_RDWR | O_CREAT | O_EXCL | PG_BINARY );
504
504
if (out < 0 )
505
505
elog (ERROR , "Cannot open temp WAL file \"%s\": %s" , to_fullpath_part , strerror (errno ));
506
506
}
@@ -513,8 +513,8 @@ push_file_internal_uncompressed(const char *wal_file_name, const char *pg_xlog_d
513
513
pg_crc32 crc32_src ;
514
514
pg_crc32 crc32_dst ;
515
515
516
- crc32_src = fio_get_crc32 (from_fullpath , FIO_DB_HOST , false, false);
517
- crc32_dst = fio_get_crc32 (to_fullpath , FIO_BACKUP_HOST , false, false);
516
+ crc32_src = fio_get_crc32 (FIO_DB_HOST , from_fullpath , false, false);
517
+ crc32_dst = fio_get_crc32 (FIO_BACKUP_HOST , to_fullpath , false, false);
518
518
519
519
if (crc32_src == crc32_dst )
520
520
{
@@ -523,7 +523,7 @@ push_file_internal_uncompressed(const char *wal_file_name, const char *pg_xlog_d
523
523
/* cleanup */
524
524
fclose (in );
525
525
fio_close (out );
526
- if (fio_remove (to_fullpath_part , false, FIO_BACKUP_HOST ) != 0 )
526
+ if (fio_remove (FIO_BACKUP_HOST , to_fullpath_part , false ) != 0 )
527
527
elog (WARNING , "Cannot remove temp WAL file \"%s\": %s" , to_fullpath_part , strerror (errno ));
528
528
return 1 ;
529
529
}
@@ -537,7 +537,7 @@ push_file_internal_uncompressed(const char *wal_file_name, const char *pg_xlog_d
537
537
/* Overwriting is forbidden,
538
538
* so we must unlink partial file and exit with error.
539
539
*/
540
- if (fio_remove (to_fullpath_part , false, FIO_BACKUP_HOST ) != 0 )
540
+ if (fio_remove (FIO_BACKUP_HOST , to_fullpath_part , false ) != 0 )
541
541
elog (WARNING , "Cannot remove temp WAL file \"%s\": %s" , to_fullpath_part , strerror (errno ));
542
542
elog (ERROR , "WAL file already exists in archive with "
543
543
"different checksum: \"%s\"" , to_fullpath );
@@ -556,7 +556,7 @@ push_file_internal_uncompressed(const char *wal_file_name, const char *pg_xlog_d
556
556
if (ferror (in ))
557
557
{
558
558
int save_errno = errno ;
559
- if (fio_remove (to_fullpath_part , false, FIO_BACKUP_HOST ) != 0 )
559
+ if (fio_remove (FIO_BACKUP_HOST , to_fullpath_part , false ) != 0 )
560
560
elog (WARNING , "Cannot remove temp WAL file \"%s\": %s" , to_fullpath_part , strerror (errno ));
561
561
elog (ERROR , "Cannot read source file \"%s\": %s" ,
562
562
from_fullpath , strerror (save_errno ));
@@ -565,7 +565,7 @@ push_file_internal_uncompressed(const char *wal_file_name, const char *pg_xlog_d
565
565
if (read_len > 0 && fio_write_async (out , buf , read_len ) != read_len )
566
566
{
567
567
int save_errno = errno ;
568
- if (fio_remove (to_fullpath_part , false, FIO_BACKUP_HOST ) != 0 )
568
+ if (fio_remove (FIO_BACKUP_HOST , to_fullpath_part , false ) != 0 )
569
569
elog (WARNING , "Cannot cleanup temp WAL file \"%s\": %s" , to_fullpath_part , strerror (errno ));
570
570
elog (ERROR , "Cannot write to destination temp file \"%s\": %s" ,
571
571
to_fullpath_part , strerror (save_errno ));
@@ -581,7 +581,7 @@ push_file_internal_uncompressed(const char *wal_file_name, const char *pg_xlog_d
581
581
/* Writing is asynchronous in case of push in remote mode, so check agent status */
582
582
if (fio_check_error_fd (out , & errmsg ))
583
583
{
584
- if (fio_remove (to_fullpath_part , false, FIO_BACKUP_HOST ) != 0 )
584
+ if (fio_remove (FIO_BACKUP_HOST , to_fullpath_part , false ) != 0 )
585
585
elog (WARNING , "Cannot cleanup temp WAL file \"%s\": %s" , to_fullpath_part , strerror (errno ));
586
586
elog (ERROR , "Cannot write to the remote file \"%s\": %s" ,
587
587
to_fullpath_part , errmsg );
@@ -591,7 +591,7 @@ push_file_internal_uncompressed(const char *wal_file_name, const char *pg_xlog_d
591
591
if (fio_close (out ) != 0 )
592
592
{
593
593
int save_errno = errno ;
594
- if (fio_remove (to_fullpath_part , false, FIO_BACKUP_HOST ) != 0 )
594
+ if (fio_remove (FIO_BACKUP_HOST , to_fullpath_part , false ) != 0 )
595
595
elog (WARNING , "Cannot cleanup temp WAL file \"%s\": %s" , to_fullpath_part , strerror (errno ));
596
596
elog (ERROR , "Cannot close temp WAL file \"%s\": %s" ,
597
597
to_fullpath_part , strerror (save_errno ));
@@ -600,7 +600,7 @@ push_file_internal_uncompressed(const char *wal_file_name, const char *pg_xlog_d
600
600
/* sync temp file to disk */
601
601
if (!no_sync )
602
602
{
603
- if (fio_sync (to_fullpath_part , FIO_BACKUP_HOST ) != 0 )
603
+ if (fio_sync (FIO_BACKUP_HOST , to_fullpath_part ) != 0 )
604
604
elog (ERROR , "Failed to sync file \"%s\": %s" ,
605
605
to_fullpath_part , strerror (errno ));
606
606
}
@@ -610,10 +610,10 @@ push_file_internal_uncompressed(const char *wal_file_name, const char *pg_xlog_d
610
610
//copy_file_attributes(from_path, FIO_DB_HOST, to_path_temp, FIO_BACKUP_HOST, true);
611
611
612
612
/* Rename temp file to destination file */
613
- if (fio_rename (to_fullpath_part , to_fullpath , FIO_BACKUP_HOST ) < 0 )
613
+ if (fio_rename (FIO_BACKUP_HOST , to_fullpath_part , to_fullpath ) < 0 )
614
614
{
615
615
int save_errno = errno ;
616
- if (fio_remove (to_fullpath_part , false, FIO_BACKUP_HOST ) != 0 )
616
+ if (fio_remove (FIO_BACKUP_HOST , to_fullpath_part , false ) != 0 )
617
617
elog (WARNING , "Cannot cleanup temp WAL file \"%s\": %s" , to_fullpath_part , strerror (errno ));
618
618
elog (ERROR , "Cannot rename file \"%s\" to \"%s\": %s" ,
619
619
to_fullpath_part , to_fullpath , strerror (save_errno ));
@@ -675,7 +675,7 @@ push_file_internal_gz(const char *wal_file_name, const char *pg_xlog_dir,
675
675
setvbuf (in , NULL , _IONBF , BUFSIZ );
676
676
677
677
/* Grab lock by creating temp file in exclusive mode */
678
- out = fio_gzopen (to_fullpath_gz_part , PG_BINARY_W , compress_level , FIO_BACKUP_HOST );
678
+ out = fio_gzopen (FIO_BACKUP_HOST , to_fullpath_gz_part , PG_BINARY_W , compress_level );
679
679
if (out == NULL )
680
680
{
681
681
if (errno != EEXIST )
@@ -701,12 +701,12 @@ push_file_internal_gz(const char *wal_file_name, const char *pg_xlog_dir,
701
701
702
702
while (partial_try_count < archive_timeout )
703
703
{
704
- if (fio_stat (to_fullpath_gz_part , & st , false, FIO_BACKUP_HOST ) < 0 )
704
+ if (fio_stat (FIO_BACKUP_HOST , to_fullpath_gz_part , & st , false) < 0 )
705
705
{
706
706
if (errno == ENOENT )
707
707
{
708
708
//part file is gone, lets try to grab it
709
- out = fio_gzopen (to_fullpath_gz_part , PG_BINARY_W , compress_level , FIO_BACKUP_HOST );
709
+ out = fio_gzopen (FIO_BACKUP_HOST , to_fullpath_gz_part , PG_BINARY_W , compress_level );
710
710
if (out == NULL )
711
711
{
712
712
if (errno != EEXIST )
@@ -755,10 +755,10 @@ push_file_internal_gz(const char *wal_file_name, const char *pg_xlog_dir,
755
755
756
756
/* Partial segment is considered stale, so reuse it */
757
757
elog (LOG , "Reusing stale temp WAL file \"%s\"" , to_fullpath_gz_part );
758
- if (fio_remove (to_fullpath_gz_part , false, FIO_BACKUP_HOST ) != 0 )
758
+ if (fio_remove (FIO_BACKUP_HOST , to_fullpath_gz_part , false ) != 0 )
759
759
elog (ERROR , "Cannot remove stale compressed temp WAL file \"%s\": %s" , to_fullpath_gz_part , strerror (errno ));
760
760
761
- out = fio_gzopen (to_fullpath_gz_part , PG_BINARY_W , compress_level , FIO_BACKUP_HOST );
761
+ out = fio_gzopen (FIO_BACKUP_HOST , to_fullpath_gz_part , PG_BINARY_W , compress_level );
762
762
if (out == NULL )
763
763
elog (ERROR , "Cannot open temp WAL file \"%s\": %s" ,
764
764
to_fullpath_gz_part , strerror (errno ));
@@ -773,8 +773,8 @@ push_file_internal_gz(const char *wal_file_name, const char *pg_xlog_dir,
773
773
pg_crc32 crc32_src ;
774
774
pg_crc32 crc32_dst ;
775
775
776
- crc32_src = fio_get_crc32 (from_fullpath , FIO_DB_HOST , false, false);
777
- crc32_dst = fio_get_crc32 (to_fullpath_gz , FIO_BACKUP_HOST , true, false);
776
+ crc32_src = fio_get_crc32 (FIO_DB_HOST , from_fullpath , false, false);
777
+ crc32_dst = fio_get_crc32 (FIO_BACKUP_HOST , to_fullpath_gz , true, false);
778
778
779
779
if (crc32_src == crc32_dst )
780
780
{
@@ -783,7 +783,7 @@ push_file_internal_gz(const char *wal_file_name, const char *pg_xlog_dir,
783
783
/* cleanup */
784
784
fclose (in );
785
785
fio_gzclose (out );
786
- if (fio_remove (to_fullpath_gz_part , false, FIO_BACKUP_HOST ) != 0 )
786
+ if (fio_remove (FIO_BACKUP_HOST , to_fullpath_gz_part , false ) != 0 )
787
787
elog (WARNING , "Cannot remove compressed temp WAL file \"%s\": %s" , to_fullpath_gz_part , strerror (errno ));
788
788
return 1 ;
789
789
}
@@ -797,7 +797,7 @@ push_file_internal_gz(const char *wal_file_name, const char *pg_xlog_dir,
797
797
/* Overwriting is forbidden,
798
798
* so we must unlink partial file and exit with error.
799
799
*/
800
- if (fio_remove (to_fullpath_gz_part , false, FIO_BACKUP_HOST ) != 0 )
800
+ if (fio_remove (FIO_BACKUP_HOST , to_fullpath_gz_part , false ) != 0 )
801
801
elog (WARNING , "Cannot remove compressed temp WAL file \"%s\": %s" , to_fullpath_gz_part , strerror (errno ));
802
802
elog (ERROR , "WAL file already exists in archive with "
803
803
"different checksum: \"%s\"" , to_fullpath_gz );
@@ -816,7 +816,7 @@ push_file_internal_gz(const char *wal_file_name, const char *pg_xlog_dir,
816
816
if (ferror (in ))
817
817
{
818
818
int save_errno = errno ;
819
- if (fio_remove (to_fullpath_gz_part , false, FIO_BACKUP_HOST ) != 0 )
819
+ if (fio_remove (FIO_BACKUP_HOST , to_fullpath_gz_part , false ) != 0 )
820
820
elog (WARNING , "Cannot remove compressed temp WAL file \"%s\": %s" , to_fullpath_gz_part , strerror (errno ));
821
821
elog (ERROR , "Cannot read from source file \"%s\": %s" ,
822
822
from_fullpath , strerror (save_errno ));
@@ -825,7 +825,7 @@ push_file_internal_gz(const char *wal_file_name, const char *pg_xlog_dir,
825
825
if (read_len > 0 && fio_gzwrite (out , buf , read_len ) != read_len )
826
826
{
827
827
int save_errno = errno ;
828
- if (fio_remove (to_fullpath_gz_part , false, FIO_BACKUP_HOST ) != 0 )
828
+ if (fio_remove (FIO_BACKUP_HOST , to_fullpath_gz_part , false ) != 0 )
829
829
elog (WARNING , "Cannot cleanup compressed temp WAL file \"%s\": %s" , to_fullpath_gz_part , strerror (errno ));
830
830
elog (ERROR , "Cannot write to compressed temp WAL file \"%s\": %s" ,
831
831
to_fullpath_gz_part , get_gz_error (out , save_errno ));
@@ -841,7 +841,7 @@ push_file_internal_gz(const char *wal_file_name, const char *pg_xlog_dir,
841
841
/* Writing is asynchronous in case of push in remote mode, so check agent status */
842
842
if (fio_check_error_fd_gz (out , & errmsg ))
843
843
{
844
- if (fio_remove (to_fullpath_gz_part , false, FIO_BACKUP_HOST ) != 0 )
844
+ if (fio_remove (FIO_BACKUP_HOST , to_fullpath_gz_part , false ) != 0 )
845
845
elog (WARNING , "Cannot cleanup remote compressed temp WAL file \"%s\": %s" , to_fullpath_gz_part , strerror (errno ));
846
846
elog (ERROR , "Cannot write to the remote compressed file \"%s\": %s" ,
847
847
to_fullpath_gz_part , errmsg );
@@ -851,7 +851,7 @@ push_file_internal_gz(const char *wal_file_name, const char *pg_xlog_dir,
851
851
if (fio_gzclose (out ) != 0 )
852
852
{
853
853
int save_errno = errno ;
854
- if (fio_remove (to_fullpath_gz_part , false, FIO_BACKUP_HOST ) != 0 )
854
+ if (fio_remove (FIO_BACKUP_HOST , to_fullpath_gz_part , false ) != 0 )
855
855
elog (WARNING , "Cannot cleanup compressed temp WAL file \"%s\": %s" , to_fullpath_gz_part , strerror (errno ));
856
856
elog (ERROR , "Cannot close compressed temp WAL file \"%s\": %s" ,
857
857
to_fullpath_gz_part , strerror (save_errno ));
@@ -860,7 +860,7 @@ push_file_internal_gz(const char *wal_file_name, const char *pg_xlog_dir,
860
860
/* sync temp file to disk */
861
861
if (!no_sync )
862
862
{
863
- if (fio_sync (to_fullpath_gz_part , FIO_BACKUP_HOST ) != 0 )
863
+ if (fio_sync (FIO_BACKUP_HOST , to_fullpath_gz_part ) != 0 )
864
864
elog (ERROR , "Failed to sync file \"%s\": %s" ,
865
865
to_fullpath_gz_part , strerror (errno ));
866
866
}
@@ -871,10 +871,10 @@ push_file_internal_gz(const char *wal_file_name, const char *pg_xlog_dir,
871
871
//copy_file_attributes(from_path, FIO_DB_HOST, to_path_temp, FIO_BACKUP_HOST, true);
872
872
873
873
/* Rename temp file to destination file */
874
- if (fio_rename (to_fullpath_gz_part , to_fullpath_gz , FIO_BACKUP_HOST ) < 0 )
874
+ if (fio_rename (FIO_BACKUP_HOST , to_fullpath_gz_part , to_fullpath_gz ) < 0 )
875
875
{
876
876
int save_errno = errno ;
877
- if (fio_remove (to_fullpath_gz_part , false, FIO_BACKUP_HOST ) != 0 )
877
+ if (fio_remove (FIO_BACKUP_HOST , to_fullpath_gz_part , false ) != 0 )
878
878
elog (WARNING , "Cannot cleanup compressed temp WAL file \"%s\": %s" , to_fullpath_gz_part , strerror (errno ));
879
879
elog (ERROR , "Cannot rename file \"%s\" to \"%s\": %s" ,
880
880
to_fullpath_gz_part , to_fullpath_gz , strerror (save_errno ));
@@ -912,15 +912,15 @@ get_gz_error(gzFile gzf, int errnum)
912
912
//{
913
913
// struct stat st;
914
914
//
915
- // if (fio_stat(from_path, &st, true, from_location ) == -1)
915
+ // if (fio_stat(from_location, from_path, &st, true) == -1)
916
916
// {
917
917
// if (unlink_on_error)
918
918
// fio_unlink(to_path, to_location);
919
919
// elog(ERROR, "Cannot stat file \"%s\": %s",
920
920
// from_path, strerror(errno));
921
921
// }
922
922
//
923
- // if (fio_chmod(to_path, st.st_mode, to_location ) == -1)
923
+ // if (fio_chmod(to_location, to_path, st.st_mode) == -1)
924
924
// {
925
925
// if (unlink_on_error)
926
926
// fio_unlink(to_path, to_location);
0 commit comments