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

redundant code #109

Open
benwaffle opened this issue Aug 17, 2014 · 0 comments
Open

redundant code #109

benwaffle opened this issue Aug 17, 2014 · 0 comments

Comments

@benwaffle
Copy link
Member

void gt::Platform::makeSharedFile()
{
    if(processIsUnique() && !checkDirExist("/tmp/gfeed")) //If the pipe already exists we'll just use it
        if(mkfifo("/tmp/gfeed", 0755) == -1)
            throw std::runtime_error("Couldn't create pipe! Check your permissions or if /tmp/gfeed exists");
    fd = open("/tmp/gfeed", O_RDONLY | O_NONBLOCK); // TODO: use streams
    if(fd == -1)
        throw std::runtime_error("Couldn't open pipe");
    if(ld == -1)
        ld = open("/var/lock/gtorrent.lock", O_CREAT | O_RDONLY, 0600);
    if(ld == -1)
        throw std::runtime_error("Couldn't open pipe");
    processIsUnique(); // a call here to lock the file
}
  • /var/lock/gtorrent.lock is not the path we use for the lock
  • the ld == -1 checks are redundant since processIsUnique will not return until ld != -1
@benwaffle benwaffle changed the title lock redundant code Aug 17, 2014
fuyukaidesu added a commit to fuyukaidesu/gtorrent-core that referenced this issue Aug 20, 2014
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

No branches or pull requests

1 participant