mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2024-12-23 01:08:54 +00:00
During the check_service function, parse a unsuccessful HTTP
return for more specific information as to why the communication failed. Most common reasons are the "time too skewed" or credentials failure. This could be extended to the curl routine that is used during normal operation. However, the check_service routine is a good first pass. Resolves issue #133 git-svn-id: http://s3fs.googlecode.com/svn/trunk@275 df820570-a93a-0410-bd06-b72b767a4274
This commit is contained in:
parent
99781e70bc
commit
412afb6953
@ -1,7 +1,7 @@
|
|||||||
dnl Process this file with autoconf to produce a configure script.
|
dnl Process this file with autoconf to produce a configure script.
|
||||||
|
|
||||||
AC_PREREQ(2.59)
|
AC_PREREQ(2.59)
|
||||||
AC_INIT(s3fs, 1.19)
|
AC_INIT(s3fs, 1.20)
|
||||||
|
|
||||||
|
|
||||||
AC_CANONICAL_SYSTEM
|
AC_CANONICAL_SYSTEM
|
||||||
|
55
src/s3fs.cpp
55
src/s3fs.cpp
@ -1751,6 +1751,8 @@ static void s3fs_check_service(void) {
|
|||||||
|
|
||||||
string responseText;
|
string responseText;
|
||||||
long responseCode;
|
long responseCode;
|
||||||
|
xmlDocPtr doc;
|
||||||
|
xmlNodePtr cur_node;
|
||||||
|
|
||||||
string resource = "/";
|
string resource = "/";
|
||||||
string url = host + resource;
|
string url = host + resource;
|
||||||
@ -1784,7 +1786,7 @@ static void s3fs_check_service(void) {
|
|||||||
// acutally made - my_curl_easy_perform doesn't differentiate
|
// acutally made - my_curl_easy_perform doesn't differentiate
|
||||||
// between the two
|
// between the two
|
||||||
|
|
||||||
CURLcode curlCode;
|
CURLcode curlCode, ccode;
|
||||||
|
|
||||||
int t = retries + 1;
|
int t = retries + 1;
|
||||||
while (t-- > 0) {
|
while (t-- > 0) {
|
||||||
@ -1856,13 +1858,43 @@ static void s3fs_check_service(void) {
|
|||||||
|
|
||||||
// Connection was made, but there is a HTTP error
|
// Connection was made, but there is a HTTP error
|
||||||
if (curlCode == CURLE_HTTP_RETURNED_ERROR) {
|
if (curlCode == CURLE_HTTP_RETURNED_ERROR) {
|
||||||
if (responseCode == 403) {
|
// Try again, but this time grab the data
|
||||||
fprintf (stderr, "%s: HTTP: 403 Forbidden - it is likely that your credentials are invalid\n",
|
curl_easy_setopt(curl, CURLOPT_FAILONERROR, false);
|
||||||
program_name.c_str());
|
ccode = curl_easy_perform(curl.get());
|
||||||
exit(1);
|
|
||||||
|
curl_easy_getinfo(curl.get(), CURLINFO_RESPONSE_CODE, &responseCode);
|
||||||
|
|
||||||
|
|
||||||
|
fprintf (stderr, "%s: CURLE_HTTP_RETURNED_ERROR\n", program_name.c_str());
|
||||||
|
fprintf (stderr, "%s: HTTP Error Code: %i\n", program_name.c_str(), (int)responseCode);
|
||||||
|
|
||||||
|
// Parse the return info
|
||||||
|
doc = xmlReadMemory(responseText.c_str(), responseText.size(), "", NULL, 0);
|
||||||
|
if (doc == NULL) {
|
||||||
|
exit(1);
|
||||||
|
|
||||||
|
}
|
||||||
|
if (doc->children == NULL) {
|
||||||
|
xmlFreeDoc(doc);
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
fprintf (stderr, "%s: HTTP: %i - report this to the s3fs developers\n",
|
|
||||||
program_name.c_str(), (int)responseCode);
|
for ( cur_node = doc->children->children;
|
||||||
|
cur_node != NULL;
|
||||||
|
cur_node = cur_node->next) {
|
||||||
|
|
||||||
|
string cur_node_name(reinterpret_cast<const char *>(cur_node->name));
|
||||||
|
|
||||||
|
if (cur_node_name == "Code") {
|
||||||
|
string content = reinterpret_cast<const char *>(cur_node->children->content);
|
||||||
|
fprintf (stderr, "%s: AWS Error Code: %s\n", program_name.c_str(), content.c_str());
|
||||||
|
}
|
||||||
|
if (cur_node_name == "Message") {
|
||||||
|
string content = reinterpret_cast<const char *>(cur_node->children->content);
|
||||||
|
fprintf (stderr, "%s: AWS Message: %s\n", program_name.c_str(), content.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xmlFreeDoc(doc);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1874,7 +1906,8 @@ static void s3fs_check_service(void) {
|
|||||||
|
|
||||||
// Parse the return info and see if the bucket is available
|
// Parse the return info and see if the bucket is available
|
||||||
|
|
||||||
xmlDocPtr doc = xmlReadMemory(responseText.c_str(), responseText.size(), "", NULL, 0);
|
|
||||||
|
doc = xmlReadMemory(responseText.c_str(), responseText.size(), "", NULL, 0);
|
||||||
if (doc == NULL) {
|
if (doc == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1889,9 +1922,9 @@ static void s3fs_check_service(void) {
|
|||||||
|
|
||||||
// Parse the XML looking for the bucket names
|
// Parse the XML looking for the bucket names
|
||||||
|
|
||||||
for (xmlNodePtr cur_node = doc->children->children;
|
for ( cur_node = doc->children->children;
|
||||||
cur_node != NULL;
|
cur_node != NULL;
|
||||||
cur_node = cur_node->next) {
|
cur_node = cur_node->next) {
|
||||||
|
|
||||||
string cur_node_name(reinterpret_cast<const char *>(cur_node->name));
|
string cur_node_name(reinterpret_cast<const char *>(cur_node->name));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user