Skip to content

Commit 4a576f7

Browse files
committed
add fdent_lock in serveral FdEntity operation
1 parent 675e62d commit 4a576f7

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
dnl Process this file with autoconf to produce a configure script.
2222

2323
AC_PREREQ(2.59)
24-
AC_INIT(cosfs, 1.0.13)
24+
AC_INIT(cosfs, 1.0.14)
2525
AC_CONFIG_HEADER([config.h])
2626

2727
AC_CANONICAL_SYSTEM

src/fdcache.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -879,10 +879,10 @@ bool FdEntity::OpenAndLoadAll(headers_t* pmeta, size_t* size, bool force_load)
879879

880880
bool FdEntity::GetStats(struct stat& st)
881881
{
882+
AutoLock auto_lock(&fdent_lock);
882883
if(-1 == fd){
883884
return false;
884885
}
885-
AutoLock auto_lock(&fdent_lock);
886886

887887
memset(&st, 0, sizeof(struct stat));
888888
if(-1 == fstat(fd, &st)){
@@ -899,8 +899,8 @@ int FdEntity::SetMtime(time_t time)
899899
if(-1 == time){
900900
return 0;
901901
}
902+
AutoLock auto_lock(&fdent_lock);
902903
if(-1 != fd){
903-
AutoLock auto_lock(&fdent_lock);
904904

905905
struct timeval tv[2];
906906
tv[0].tv_sec = time;
@@ -928,6 +928,7 @@ int FdEntity::SetMtime(time_t time)
928928

929929
bool FdEntity::UpdateMtime(void)
930930
{
931+
AutoLock auto_lock(&fdent_lock);
931932
struct stat st;
932933
if(!GetStats(st)){
933934
return false;
@@ -949,18 +950,21 @@ bool FdEntity::GetSize(size_t& size)
949950

950951
bool FdEntity::SetMode(mode_t mode)
951952
{
953+
AutoLock auto_lock(&fdent_lock);
952954
orgmeta["x-cos-meta-mode"] = str(mode);
953955
return true;
954956
}
955957

956958
bool FdEntity::SetUId(uid_t uid)
957959
{
960+
AutoLock auto_lock(&fdent_lock);
958961
orgmeta["x-cos-meta-uid"] = str(uid);
959962
return true;
960963
}
961964

962965
bool FdEntity::SetGId(gid_t gid)
963966
{
967+
AutoLock auto_lock(&fdent_lock);
964968
orgmeta["x-cos-meta-gid"] = str(gid);
965969
return true;
966970
}
@@ -970,6 +974,7 @@ bool FdEntity::SetContentType(const char* path)
970974
if(!path){
971975
return false;
972976
}
977+
AutoLock auto_lock(&fdent_lock);
973978
orgmeta["Content-Type"] = S3fsCurl::LookupMimeType(string(path));
974979
return true;
975980
}
@@ -1885,6 +1890,7 @@ FdEntity* FdManager::ExistOpen(const char* path, int existfd, bool ignore_existf
18851890

18861891
void FdManager::Rename(const std::string &from, const std::string &to)
18871892
{
1893+
AutoLock auto_lock(&FdManager::fd_manager_lock);
18881894
fdent_map_t::iterator iter = fent.find(from);
18891895
if(fent.end() != iter){
18901896
// found

0 commit comments

Comments
 (0)