Skip to content

Commit

Permalink
Remove unneeded lock utility functions (s3fs-fuse#2500)
Browse files Browse the repository at this point in the history
std::mutex RAII removes the need for these.

Co-authored-by: Takeshi Nakatani <[email protected]>
  • Loading branch information
gaul and ggtakec authored Jul 15, 2024
1 parent 23efccb commit 1c2f61e
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 66 deletions.
38 changes: 0 additions & 38 deletions src/s3fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5620,21 +5620,6 @@ int main(int argc, char* argv[])
exit(EXIT_FAILURE);
}

// mutex for xml
if(!init_parser_xml_lock()){
S3FS_PRN_EXIT("could not initialize mutex for xml parser.");
s3fs_destroy_global_ssl();
exit(EXIT_FAILURE);
}

// mutex for basename/dirname
if(!init_basename_lock()){
S3FS_PRN_EXIT("could not initialize mutex for basename/dirname.");
s3fs_destroy_global_ssl();
destroy_parser_xml_lock();
exit(EXIT_FAILURE);
}

// init curl (without mime types)
//
// [NOTE]
Expand All @@ -5654,8 +5639,6 @@ int main(int argc, char* argv[])
if(!S3fsCurl::InitS3fsCurl()){
S3FS_PRN_EXIT("Could not initiate curl library.");
s3fs_destroy_global_ssl();
destroy_parser_xml_lock();
destroy_basename_lock();
exit(EXIT_FAILURE);
}

Expand All @@ -5666,8 +5649,6 @@ int main(int argc, char* argv[])
if(0 != fuse_opt_parse(&custom_args, nullptr, nullptr, my_fuse_opt_proc)){
S3fsCurl::DestroyS3fsCurl();
s3fs_destroy_global_ssl();
destroy_parser_xml_lock();
destroy_basename_lock();
exit(EXIT_FAILURE);
}

Expand All @@ -5683,16 +5664,12 @@ int main(int argc, char* argv[])
S3FS_PRN_EXIT("use_sse option could not be specified with storage class reduced_redundancy.");
S3fsCurl::DestroyS3fsCurl();
s3fs_destroy_global_ssl();
destroy_parser_xml_lock();
destroy_basename_lock();
exit(EXIT_FAILURE);
}
if(!S3fsCurl::FinalCheckSse()){
S3FS_PRN_EXIT("something wrong about SSE options.");
S3fsCurl::DestroyS3fsCurl();
s3fs_destroy_global_ssl();
destroy_parser_xml_lock();
destroy_basename_lock();
exit(EXIT_FAILURE);
}

Expand All @@ -5711,8 +5688,6 @@ int main(int argc, char* argv[])
if(!ps3fscred->CheckAllParams()){
S3fsCurl::DestroyS3fsCurl();
s3fs_destroy_global_ssl();
destroy_parser_xml_lock();
destroy_basename_lock();
exit(EXIT_FAILURE);
}

Expand All @@ -5726,8 +5701,6 @@ int main(int argc, char* argv[])
show_usage();
S3fsCurl::DestroyS3fsCurl();
s3fs_destroy_global_ssl();
destroy_parser_xml_lock();
destroy_basename_lock();
exit(EXIT_FAILURE);
}
}
Expand All @@ -5737,8 +5710,6 @@ int main(int argc, char* argv[])
S3FS_PRN_EXIT("temporary directory doesn't exists.");
S3fsCurl::DestroyS3fsCurl();
s3fs_destroy_global_ssl();
destroy_parser_xml_lock();
destroy_basename_lock();
exit(EXIT_FAILURE);
}

Expand All @@ -5747,8 +5718,6 @@ int main(int argc, char* argv[])
S3FS_PRN_EXIT("could not allow cache directory permission, check permission of cache directories.");
S3fsCurl::DestroyS3fsCurl();
s3fs_destroy_global_ssl();
destroy_parser_xml_lock();
destroy_basename_lock();
exit(EXIT_FAILURE);
}

Expand Down Expand Up @@ -5795,7 +5764,6 @@ int main(int argc, char* argv[])
S3FS_PRN_EXIT("Using https and a bucket name with periods is unsupported.");
S3fsCurl::DestroyS3fsCurl();
s3fs_destroy_global_ssl();
destroy_parser_xml_lock();
exit(EXIT_FAILURE);
}
}
Expand All @@ -5807,8 +5775,6 @@ int main(int argc, char* argv[])

S3fsCurl::DestroyS3fsCurl();
s3fs_destroy_global_ssl();
destroy_parser_xml_lock();
destroy_basename_lock();
exit(exitcode);
}

Expand All @@ -5827,8 +5793,6 @@ int main(int argc, char* argv[])
if(!FdManager::IsSafeDiskSpaceWithLog(nullptr, S3fsCurl::GetMultipartSize() * S3fsCurl::GetMaxParallelCount())){
S3fsCurl::DestroyS3fsCurl();
s3fs_destroy_global_ssl();
destroy_parser_xml_lock();
destroy_basename_lock();
exit(EXIT_FAILURE);
}
}
Expand Down Expand Up @@ -5886,8 +5850,6 @@ int main(int argc, char* argv[])
S3FS_PRN_WARN("Could not release curl library.");
}
s3fs_destroy_global_ssl();
destroy_parser_xml_lock();
destroy_basename_lock();

// cleanup xml2
xmlCleanupParser();
Expand Down
10 changes: 0 additions & 10 deletions src/s3fs_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,6 @@ int is_uid_include_group(uid_t uid, gid_t gid)
//
static std::mutex basename_lock;

bool init_basename_lock()
{
return true;
}

bool destroy_basename_lock()
{
return true;
}

std::string mydirname(const std::string& path)
{
const std::lock_guard<std::mutex> lock(basename_lock);
Expand Down
2 changes: 0 additions & 2 deletions src/s3fs_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ void init_sysconf_vars();
std::string get_username(uid_t uid);
int is_uid_include_group(uid_t uid, gid_t gid);

bool init_basename_lock();
bool destroy_basename_lock();
std::string mydirname(const char* path);
std::string mydirname(const std::string& path);
std::string mybasename(const char* path);
Expand Down
13 changes: 0 additions & 13 deletions src/s3fs_xml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,19 +481,6 @@ bool simple_parse_xml(const char* data, size_t len, const char* key, std::string
return result;
}

//-------------------------------------------------------------------
// Utility for lock
//-------------------------------------------------------------------
bool init_parser_xml_lock()
{
return true;
}

bool destroy_parser_xml_lock()
{
return true;
}

/*
* Local variables:
* tab-width: 4
Expand Down
3 changes: 0 additions & 3 deletions src/s3fs_xml.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ bool get_incomp_mpu_list(xmlDocPtr doc, incomp_mpu_list_t& list);

bool simple_parse_xml(const char* data, size_t len, const char* key, std::string& value);

bool init_parser_xml_lock();
bool destroy_parser_xml_lock();

#endif // S3FS_S3FS_XML_H_

/*
Expand Down

0 comments on commit 1c2f61e

Please sign in to comment.