Index: native_client_sdk/src/libraries/nacl_io/mount_node_http.cc |
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_node_http.cc b/native_client_sdk/src/libraries/nacl_io/mount_node_http.cc |
index 5a65d413de36d04fe4e7078f97c6ee8ce48aa517..b7e1df68240533516c623cb5ad7f809a2635e4db 100644 |
--- a/native_client_sdk/src/libraries/nacl_io/mount_node_http.cc |
+++ b/native_client_sdk/src/libraries/nacl_io/mount_node_http.cc |
@@ -151,14 +151,14 @@ void MountNodeHttp::SetCachedSize(off_t size) { |
stat_.st_size = size; |
} |
-Error MountNodeHttp::FSync() { return ENOSYS; } |
+Error MountNodeHttp::FSync() { return EACCES; } |
Error MountNodeHttp::GetDents(size_t offs, |
struct dirent* pdir, |
size_t count, |
int* out_bytes) { |
*out_bytes = 0; |
- return ENOSYS; |
+ return EACCES; |
} |
Error MountNodeHttp::GetStat(struct stat* stat) { |
@@ -193,10 +193,8 @@ Error MountNodeHttp::GetStat(struct stat* stat) { |
SetCachedSize(static_cast<off_t>(entity_length)); |
} else if (cache_content_ && !has_cached_size_) { |
error = DownloadToCache(); |
- // TODO(binji): this error should not be dropped, but it requires a bit |
- // of a refactor of the tests. See crbug.com/245431 |
- // if (error) |
- // return error; |
+ if (error) |
+ return error; |
} else { |
// Don't use SetCachedSize here -- it is actually unknown. |
stat_.st_size = 0; |
@@ -236,7 +234,7 @@ Error MountNodeHttp::Read(const HandleAttr& attr, |
return DownloadPartial(attr.offs, buf, count, out_bytes); |
} |
-Error MountNodeHttp::FTruncate(off_t size) { return ENOSYS; } |
+Error MountNodeHttp::FTruncate(off_t size) { return EACCES; } |
Error MountNodeHttp::Write(const HandleAttr& attr, |
const void* buf, |
@@ -244,7 +242,7 @@ Error MountNodeHttp::Write(const HandleAttr& attr, |
int* out_bytes) { |
// TODO(binji): support POST? |
*out_bytes = 0; |
- return ENOSYS; |
+ return EACCES; |
} |
Error MountNodeHttp::GetSize(size_t* out_size) { |
@@ -342,6 +340,8 @@ Error MountNodeHttp::OpenUrl(const char* method, |
*out_response_headers = |
ParseHeaders(response_headers_str, response_headers_length); |
+ var_interface->Release(response_headers_var); |
+ |
return 0; |
} |
@@ -409,13 +409,15 @@ Error MountNodeHttp::ReadPartialFromCache(size_t offs, |
int count, |
int* out_bytes) { |
*out_bytes = 0; |
+ size_t size = cached_data_.size(); |
- if (offs > cached_data_.size()) |
- return EINVAL; |
+ if (offs + count > size) |
+ count = size - offs; |
Sam Clegg
2013/11/20 20:00:54
So this function can no longer fail? Might be wor
binji
2013/11/20 20:34:17
Hm. I like that it has the same signature as the r
|
- count = std::min(count, static_cast<int>(cached_data_.size() - offs)); |
- memcpy(buf, &cached_data_.data()[offs], count); |
+ if (count <= 0) |
+ return 0; |
+ memcpy(buf, &cached_data_.data()[offs], count); |
*out_bytes = count; |
return 0; |
} |