mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2024-12-23 09:18:55 +00:00
Fixed issue: 320
1) Changes calling fread/fwrite logic(Issue: 320) The calling fread/fwrite function logic is changed those in loop. If the fread/fwrite returns 0 byte without a error, s3fs continue(retry) to read/write. git-svn-id: http://s3fs.googlecode.com/svn/trunk@408 df820570-a93a-0410-bd06-b72b767a4274
This commit is contained in:
parent
9310c0b653
commit
a632af8f90
80
src/s3fs.cpp
80
src/s3fs.cpp
@ -772,12 +772,13 @@ static int put_local_fd_big_file(const char* path, headers_t meta, int fd) {
|
|||||||
// cycle through open fd, pulling off 10MB chunks at a time
|
// cycle through open fd, pulling off 10MB chunks at a time
|
||||||
while(lSize > 0) {
|
while(lSize > 0) {
|
||||||
file_part part;
|
file_part part;
|
||||||
|
size_t totalSize;
|
||||||
|
|
||||||
if(lSize >= MULTIPART_SIZE)
|
if(lSize >= MULTIPART_SIZE){
|
||||||
lBufferSize = MULTIPART_SIZE;
|
lBufferSize = MULTIPART_SIZE;
|
||||||
else
|
}else{
|
||||||
lBufferSize = lSize;
|
lBufferSize = lSize;
|
||||||
|
}
|
||||||
lSize = lSize - lBufferSize;
|
lSize = lSize - lBufferSize;
|
||||||
|
|
||||||
if((buffer = (char *) malloc(sizeof(char) * lBufferSize)) == NULL) {
|
if((buffer = (char *) malloc(sizeof(char) * lBufferSize)) == NULL) {
|
||||||
@ -787,23 +788,35 @@ static int put_local_fd_big_file(const char* path, headers_t meta, int fd) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// copy the file portion into the buffer:
|
// copy the file portion into the buffer:
|
||||||
bytesRead = fread(buffer, 1, lBufferSize, pSourceFile);
|
for(totalSize = 0; totalSize < lBufferSize; totalSize += bytesRead){
|
||||||
if(bytesRead != lBufferSize) {
|
bytesRead = fread(&buffer[totalSize], 1, (lBufferSize - totalSize), pSourceFile);
|
||||||
SYSLOGERR("%d ### bytesRead:%zu does not match lBufferSize: %lu\n",
|
if(bytesRead != (lBufferSize - totalSize)){
|
||||||
__LINE__, bytesRead, lBufferSize);
|
int nError;
|
||||||
|
if(0 != (nError = ferror(pSourceFile))){
|
||||||
if(buffer)
|
SYSLOGERR("%d ### read file error(%d): bytesRead:%zu does not match (lBufferSize - totalSize): %lu\n",
|
||||||
free(buffer);
|
__LINE__, nError, bytesRead, (lBufferSize - totalSize));
|
||||||
|
if(buffer){
|
||||||
return(-EIO);
|
free(buffer);
|
||||||
}
|
}
|
||||||
|
return(-EIO);
|
||||||
|
}
|
||||||
|
if(feof(pSourceFile)){
|
||||||
|
SYSLOGERR("%d ### read end of file: bytesRead:%zu does not match (lBufferSize - totalSize): %lu\n",
|
||||||
|
__LINE__, bytesRead, (lBufferSize - totalSize));
|
||||||
|
if(buffer){
|
||||||
|
free(buffer);
|
||||||
|
}
|
||||||
|
return(-EIO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// create uniq temporary file
|
// create uniq temporary file
|
||||||
strncpy(part.path, "/tmp/s3fs.XXXXXX", sizeof part.path);
|
strncpy(part.path, "/tmp/s3fs.XXXXXX", sizeof part.path);
|
||||||
if((partfd = mkstemp(part.path)) == -1) {
|
if((partfd = mkstemp(part.path)) == -1) {
|
||||||
if(buffer)
|
if(buffer){
|
||||||
free(buffer);
|
free(buffer);
|
||||||
|
}
|
||||||
YIKES(-errno);
|
YIKES(-errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -811,34 +824,39 @@ static int put_local_fd_big_file(const char* path, headers_t meta, int fd) {
|
|||||||
if((pPartFile = fdopen(partfd, "wb")) == NULL) {
|
if((pPartFile = fdopen(partfd, "wb")) == NULL) {
|
||||||
SYSLOGERR("%d ### Could not open temporary file: errno %i\n", __LINE__, errno);
|
SYSLOGERR("%d ### Could not open temporary file: errno %i\n", __LINE__, errno);
|
||||||
close(partfd);
|
close(partfd);
|
||||||
if(buffer)
|
if(buffer){
|
||||||
free(buffer);
|
free(buffer);
|
||||||
|
}
|
||||||
return(-errno);
|
return(-errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy buffer to temporary file
|
// copy buffer to temporary file
|
||||||
bytesWritten = fwrite(buffer, 1, (size_t)lBufferSize, pPartFile);
|
for(totalSize = 0; totalSize < lBufferSize; totalSize += bytesWritten){
|
||||||
if(bytesWritten != lBufferSize) {
|
bytesWritten = fwrite(&buffer[totalSize], 1, (size_t)(lBufferSize - totalSize), pPartFile);
|
||||||
SYSLOGERR("%d ### bytesWritten:%zu does not match lBufferSize: %lu\n",
|
if(bytesWritten != (lBufferSize - totalSize)){
|
||||||
__LINE__, bytesWritten, lBufferSize);
|
int nError;
|
||||||
|
if(0 != (nError = ferror(pPartFile))){
|
||||||
|
SYSLOGERR("%d ### write file error(%d): bytesWritten:%zu does not match (lBufferSize - totalSize): %lu\n",
|
||||||
|
__LINE__, nError, bytesWritten, (lBufferSize - totalSize));
|
||||||
|
fclose(pPartFile);
|
||||||
|
if(buffer){
|
||||||
|
free(buffer);
|
||||||
|
}
|
||||||
|
return(-EIO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fclose(pPartFile);
|
|
||||||
if(buffer)
|
|
||||||
free(buffer);
|
|
||||||
|
|
||||||
return(-EIO);
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(pPartFile);
|
fclose(pPartFile);
|
||||||
if(buffer)
|
if(buffer){
|
||||||
free(buffer);
|
free(buffer);
|
||||||
|
}
|
||||||
part.etag = upload_part(path, part.path, parts.size() + 1, uploadId);
|
part.etag = upload_part(path, part.path, parts.size() + 1, uploadId);
|
||||||
|
|
||||||
// delete temporary part file
|
// delete temporary part file
|
||||||
if(remove(part.path) != 0)
|
if(remove(part.path) != 0){
|
||||||
YIKES(-errno);
|
YIKES(-errno);
|
||||||
|
}
|
||||||
|
|
||||||
parts.push_back(part);
|
parts.push_back(part);
|
||||||
} // while(lSize > 0)
|
} // while(lSize > 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user