File tree Expand file tree Collapse file tree 1 file changed +25
-21
lines changed Expand file tree Collapse file tree 1 file changed +25
-21
lines changed Original file line number Diff line number Diff line change @@ -3828,6 +3828,27 @@ mdb_env_get_maxreaders(MDB_env *env, unsigned int *readers)
3828
3828
return MDB_SUCCESS ;
3829
3829
}
3830
3830
3831
+ static int ESECT
3832
+ mdb_fsize (HANDLE fd , size_t * size )
3833
+ {
3834
+ #ifdef WIN32
3835
+ LARGE_INTEGER fsize ;
3836
+
3837
+ if (!GetFileSizeEx (fd , & fsize ))
3838
+ return ErrCode ();
3839
+
3840
+ * size = fsize .QuadPart ;
3841
+ #else
3842
+ struct stat st ;
3843
+
3844
+ if (fstat (fd , & st ))
3845
+ return ErrCode ();
3846
+
3847
+ * size = st .st_size ;
3848
+ #endif
3849
+ return MDB_SUCCESS ;
3850
+ }
3851
+
3831
3852
/** Further setup required for opening an LMDB environment
3832
3853
*/
3833
3854
static int ESECT
@@ -8690,30 +8711,13 @@ mdb_env_copyfd0(MDB_env *env, HANDLE fd)
8690
8711
goto leave ;
8691
8712
8692
8713
w2 = txn -> mt_next_pgno * env -> me_psize ;
8693
- #ifdef WIN32
8694
8714
{
8695
- LARGE_INTEGER fsize ;
8696
-
8697
- if (!GetFileSizeEx (env -> me_fd , & fsize )) {
8698
- rc = ErrCode ();
8715
+ size_t fsize = 0 ;
8716
+ if ((rc = mdb_fsize (env -> me_fd , & fsize )))
8699
8717
goto leave ;
8700
- }
8701
-
8702
- if (w2 > fsize .QuadPart )
8703
- w2 = fsize .QuadPart ;
8718
+ if (w2 > fsize )
8719
+ w2 = fsize ;
8704
8720
}
8705
- #else
8706
- {
8707
- struct stat st ;
8708
-
8709
- if ((rc = fstat (env -> me_fd , & st ))) {
8710
- goto leave ;
8711
- }
8712
-
8713
- if (w2 > (size_t )st .st_size )
8714
- w2 = st .st_size ;
8715
- }
8716
- #endif
8717
8721
wsize = w2 - wsize ;
8718
8722
while (wsize > 0 ) {
8719
8723
if (wsize > MAX_WRITE )
You can’t perform that action at this time.
0 commit comments