Merge pull request #663 from gaul/orgmeta-lock

Lock FdEntity when mutating orgmeta
This commit is contained in:
Takeshi Nakatani 2017-11-05 13:53:14 +09:00 committed by GitHub
commit df3803c7b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1017,9 +1017,9 @@ int FdEntity::SetMtime(time_t time)
if(-1 == time){
return 0;
}
if(-1 != fd){
AutoLock auto_lock(&fdent_lock);
AutoLock auto_lock(&fdent_lock);
if(-1 != fd){
struct timeval tv[2];
tv[0].tv_sec = time;
tv[0].tv_usec= 0L;
@ -1046,6 +1046,7 @@ int FdEntity::SetMtime(time_t time)
bool FdEntity::UpdateMtime(void)
{
AutoLock auto_lock(&fdent_lock);
struct stat st;
if(!GetStats(st)){
return false;
@ -1067,18 +1068,21 @@ bool FdEntity::GetSize(size_t& size)
bool FdEntity::SetMode(mode_t mode)
{
AutoLock auto_lock(&fdent_lock);
orgmeta["x-amz-meta-mode"] = str(mode);
return true;
}
bool FdEntity::SetUId(uid_t uid)
{
AutoLock auto_lock(&fdent_lock);
orgmeta["x-amz-meta-uid"] = str(uid);
return true;
}
bool FdEntity::SetGId(gid_t gid)
{
AutoLock auto_lock(&fdent_lock);
orgmeta["x-amz-meta-gid"] = str(gid);
return true;
}
@ -1088,6 +1092,7 @@ bool FdEntity::SetContentType(const char* path)
if(!path){
return false;
}
AutoLock auto_lock(&fdent_lock);
orgmeta["Content-Type"] = S3fsCurl::LookupMimeType(string(path));
return true;
}