Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix issue#8 #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

fix: fix issue#8 #11

wants to merge 2 commits into from

Conversation

Yangfisher1
Copy link

Fix the issue#8, now small files can also be transferred successfully.

@roidayan
Copy link
Owner

thanks for submitting fixes. can you fix the commit msgs to have a title and description if needed to explain the fix. the fix issue line can be as part of the description.

@@ -1179,7 +1179,7 @@ static int rdcp_test_client(struct rdcp_cb *cb)
VERBOSE_LOG(1, "done\n");

out:
fclose(cb->fp);
// fclose(cb->fp);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont leave commented out code. also how does it fix anything? why do skip closing the file pointer?

cb->metadata.size = ftell(cb->fp);
// cb->fp = fdopen(cb->fd, "rb");
// fseek(cb->fp, 0, SEEK_END);
// cb->metadata.size = ftell(cb->fp);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont leave commented out code.

// fseek(cb->fp, 0, SEEK_END);
// cb->metadata.size = ftell(cb->fp);
stat(cb->metadata.src_path, &filebuf);
cb->metadata.size = filebuf.st_size;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how is using stat() instead of fseek() helps here? stat() is great and has better performance but beside that i dont see how it fix an issue. if you can change your commit to explain to use stat() instead of fseek() its fine by me to accept the commit anyway. but it is requiring some explanation why/how it fixes the issue with small files.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm inspired by issue#8. After read the issue, I searched the Internet for the difference between stat() and fseek(). I believed that it might have some conflicts between a file pointer(cb->fp) and a file descriptor(cb->fd), so it'd better use just a file pointer or just a file descriptor rather than hybird, and using stat() can simply and easily get the whole file's length without moving position(which I thought the bug happened), but actually I didn't know exactly why this happened, sorry.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok and it is fine by me but need to refactor the patch to have a meaningful title and description.
you can just say use stat() to get the file size and the body will be to fix issue #8 and its fine by me. also need to clean commented out code. there is no point to leave this.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok and it is fine by me but need to refactor the patch to have a meaningful title and description.
you can just say use stat() to get the file size and the body will be to fix issue #8 and its fine by me. also need to clean commented out code. there is no point to leave this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants