mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2025-04-10 18:41:53 +00:00
Merge pull request #319 from RobbKistler/clean-exit
Clean up mount point on errors in s3fs_init()
This commit is contained in:
commit
1e1f2a66de
23
src/s3fs.cpp
23
src/s3fs.cpp
@ -89,6 +89,7 @@ bool foreground = false;
|
|||||||
bool nomultipart = false;
|
bool nomultipart = false;
|
||||||
bool pathrequeststyle = false;
|
bool pathrequeststyle = false;
|
||||||
bool is_specified_endpoint = false;
|
bool is_specified_endpoint = false;
|
||||||
|
int s3fs_init_deferred_exit_status = 0;
|
||||||
std::string program_name;
|
std::string program_name;
|
||||||
std::string service_path = "/";
|
std::string service_path = "/";
|
||||||
std::string host = "http://s3.amazonaws.com";
|
std::string host = "http://s3.amazonaws.com";
|
||||||
@ -3292,6 +3293,19 @@ static int s3fs_removexattr(const char* path, const char* name)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// s3fs_init calls this function to exit cleanly from the fuse event loop.
|
||||||
|
//
|
||||||
|
// There's no way to pass an exit status to the high-level event loop API, so
|
||||||
|
// this function stores the exit value in a global for main()
|
||||||
|
static void s3fs_exit_fuseloop(int exit_status) {
|
||||||
|
S3FS_PRN_ERR("Exiting FUSE event loop due to errors\n");
|
||||||
|
s3fs_init_deferred_exit_status = exit_status;
|
||||||
|
struct fuse_context *ctx = fuse_get_context();
|
||||||
|
if (NULL != ctx) {
|
||||||
|
fuse_exit(ctx->fuse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void* s3fs_init(struct fuse_conn_info* conn)
|
static void* s3fs_init(struct fuse_conn_info* conn)
|
||||||
{
|
{
|
||||||
S3FS_PRN_CRIT("init v%s(commit:%s) with %s", VERSION, COMMIT_HASH_VAL, s3fs_crypt_lib_name());
|
S3FS_PRN_CRIT("init v%s(commit:%s) with %s", VERSION, COMMIT_HASH_VAL, s3fs_crypt_lib_name());
|
||||||
@ -3299,13 +3313,15 @@ static void* s3fs_init(struct fuse_conn_info* conn)
|
|||||||
// ssl init
|
// ssl init
|
||||||
if(!s3fs_init_global_ssl()){
|
if(!s3fs_init_global_ssl()){
|
||||||
S3FS_PRN_CRIT("could not initialize for ssl libraries.");
|
S3FS_PRN_CRIT("could not initialize for ssl libraries.");
|
||||||
exit(EXIT_FAILURE);
|
s3fs_exit_fuseloop(EXIT_FAILURE);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// init curl
|
// init curl
|
||||||
if(!S3fsCurl::InitS3fsCurl("/etc/mime.types")){
|
if(!S3fsCurl::InitS3fsCurl("/etc/mime.types")){
|
||||||
S3FS_PRN_CRIT("Could not initiate curl library.");
|
S3FS_PRN_CRIT("Could not initiate curl library.");
|
||||||
exit(EXIT_FAILURE);
|
s3fs_exit_fuseloop(EXIT_FAILURE);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (create_bucket){
|
if (create_bucket){
|
||||||
@ -3318,7 +3334,8 @@ static void* s3fs_init(struct fuse_conn_info* conn)
|
|||||||
if(!S3fsCurl::IsPublicBucket()){
|
if(!S3fsCurl::IsPublicBucket()){
|
||||||
int result;
|
int result;
|
||||||
if(EXIT_SUCCESS != (result = s3fs_check_service())){
|
if(EXIT_SUCCESS != (result = s3fs_check_service())){
|
||||||
exit(result);
|
s3fs_exit_fuseloop(result);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ function exit_handler {
|
|||||||
then
|
then
|
||||||
kill $S3PROXY_PID
|
kill $S3PROXY_PID
|
||||||
fi
|
fi
|
||||||
retry 30 fusermount -u $TEST_BUCKET_MOUNT_POINT_1
|
retry 30 grep $TEST_BUCKET_MOUNT_POINT_1 /proc/mounts && fusermount -u $TEST_BUCKET_MOUNT_POINT_1
|
||||||
}
|
}
|
||||||
trap exit_handler EXIT
|
trap exit_handler EXIT
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user