77 * Portions Copyright (c) 1994, Regents of the University of California
88 *
99 * IDENTIFICATION
10- * $Header: /cvsroot/pgsql/src/backend/storage/file/fd.c,v 1.87 2001/11/05 17:46:27 momjian Exp $
10+ * $Header: /cvsroot/pgsql/src/backend/storage/file/fd.c,v 1.88 2002/02/10 22:56:31 tgl Exp $
1111 *
1212 * NOTES:
1313 *
@@ -110,7 +110,7 @@ int max_files_per_process = 1000;
110110
111111#define FileIsNotOpen (file ) (VfdCache[file].fd == VFD_CLOSED)
112112
113- #define FileUnknownPos (-1 )
113+ #define FileUnknownPos (-1L )
114114
115115typedef struct vfd
116116{
@@ -380,7 +380,6 @@ static void
380380LruDelete (File file )
381381{
382382 Vfd * vfdP ;
383- int returnValue ;
384383
385384 Assert (file != 0 );
386385
@@ -394,19 +393,21 @@ LruDelete(File file)
394393
395394 /* save the seek position */
396395 vfdP -> seekPos = (long ) lseek (vfdP -> fd , 0L , SEEK_CUR );
397- Assert (vfdP -> seekPos != -1 );
396+ Assert (vfdP -> seekPos != -1L );
398397
399398 /* if we have written to the file, sync it before closing */
400399 if (vfdP -> fdstate & FD_DIRTY )
401400 {
402- returnValue = pg_fsync (vfdP -> fd );
403- Assert (returnValue != -1 );
401+ if (pg_fsync (vfdP -> fd ))
402+ elog (DEBUG , "LruDelete: failed to fsync %s: %m" ,
403+ vfdP -> fileName );
404404 vfdP -> fdstate &= ~FD_DIRTY ;
405405 }
406406
407407 /* close the file */
408- returnValue = close (vfdP -> fd );
409- Assert (returnValue != -1 );
408+ if (close (vfdP -> fd ))
409+ elog (DEBUG , "LruDelete: failed to close %s: %m" ,
410+ vfdP -> fileName );
410411
411412 -- nfile ;
412413 vfdP -> fd = VFD_CLOSED ;
@@ -437,7 +438,6 @@ static int
437438LruInsert (File file )
438439{
439440 Vfd * vfdP ;
440- int returnValue ;
441441
442442 Assert (file != 0 );
443443
@@ -475,8 +475,10 @@ LruInsert(File file)
475475 /* seek to the right position */
476476 if (vfdP -> seekPos != 0L )
477477 {
478- returnValue = lseek (vfdP -> fd , vfdP -> seekPos , SEEK_SET );
479- Assert (returnValue != -1 );
478+ long returnValue ;
479+
480+ returnValue = (long ) lseek (vfdP -> fd , vfdP -> seekPos , SEEK_SET );
481+ Assert (returnValue != -1L );
480482 }
481483 }
482484
@@ -824,43 +826,48 @@ OpenTemporaryFile(void)
824826void
825827FileClose (File file )
826828{
827- int returnValue ;
829+ Vfd * vfdP ;
828830
829831 Assert (FileIsValid (file ));
830832
831833 DO_DB (elog (DEBUG , "FileClose: %d (%s)" ,
832834 file , VfdCache [file ].fileName ));
833835
836+ vfdP = & VfdCache [file ];
837+
834838 if (!FileIsNotOpen (file ))
835839 {
836-
837840 /* remove the file from the lru ring */
838841 Delete (file );
839842
840843 /* if we did any writes, sync the file before closing */
841- if (VfdCache [ file ]. fdstate & FD_DIRTY )
844+ if (vfdP -> fdstate & FD_DIRTY )
842845 {
843- returnValue = pg_fsync (VfdCache [file ].fd );
844- Assert (returnValue != -1 );
845- VfdCache [file ].fdstate &= ~FD_DIRTY ;
846+ if (pg_fsync (vfdP -> fd ))
847+ elog (DEBUG , "FileClose: failed to fsync %s: %m" ,
848+ vfdP -> fileName );
849+ vfdP -> fdstate &= ~FD_DIRTY ;
846850 }
847851
848852 /* close the file */
849- returnValue = close (VfdCache [file ].fd );
850- Assert (returnValue != -1 );
853+ if (close (vfdP -> fd ))
854+ elog (DEBUG , "FileClose: failed to close %s: %m" ,
855+ vfdP -> fileName );
851856
852857 -- nfile ;
853- VfdCache [ file ]. fd = VFD_CLOSED ;
858+ vfdP -> fd = VFD_CLOSED ;
854859 }
855860
856861 /*
857862 * Delete the file if it was temporary
858863 */
859- if (VfdCache [ file ]. fdstate & FD_TEMPORARY )
864+ if (vfdP -> fdstate & FD_TEMPORARY )
860865 {
861866 /* reset flag so that die() interrupt won't cause problems */
862- VfdCache [file ].fdstate &= ~FD_TEMPORARY ;
863- unlink (VfdCache [file ].fileName );
867+ vfdP -> fdstate &= ~FD_TEMPORARY ;
868+ if (unlink (vfdP -> fileName ))
869+ elog (DEBUG , "FileClose: failed to unlink %s: %m" ,
870+ vfdP -> fileName );
864871 }
865872
866873 /*
0 commit comments