Skip to content
Snippets Groups Projects
Select Git revision
2 results Searching

test_fsig.py

Blame
  • Forked from finesse / pykat
    Source project has a limited visibility.
    cs_files.cpp 11.27 KiB
    // This file is part of BOINC.
    // http://boinc.berkeley.edu
    // Copyright (C) 2008 University of California
    //
    // BOINC is free software; you can redistribute it and/or modify it
    // under the terms of the GNU Lesser General Public License
    // as published by the Free Software Foundation,
    // either version 3 of the License, or (at your option) any later version.
    //
    // BOINC is distributed in the hope that it will be useful,
    // but WITHOUT ANY WARRANTY; without even the implied warranty of
    // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    // See the GNU Lesser General Public License for more details.
    //
    // You should have received a copy of the GNU Lesser General Public License
    // along with BOINC.  If not, see <http://www.gnu.org/licenses/>.
    
    // The "policy" part of file transfer is here.
    // The "mechanism" part is in pers_file_xfer.C and file_xfer.C
    //
    
    #include "cpp.h"
    
    #ifdef _WIN32
    #include "boinc_win.h"
    #else
    #include "config.h"
    #include <cassert>
    #include <sys/stat.h>
    #include <sys/types.h>
    #endif
    
    #include "md5_file.h"
    #include "crypt.h"
    #include "str_util.h"
    #include "filesys.h"
    #include "cert_sig.h"
    #include "error_numbers.h"
    
    #include "file_names.h"
    #include "client_types.h"
    #include "client_state.h"
    #include "client_msgs.h"
    #include "file_xfer.h"
    
    using std::vector;
    
    // Decide whether to consider starting a new file transfer
    //
    bool CLIENT_STATE::start_new_file_xfer(PERS_FILE_XFER& pfx) {
        unsigned int i;
        int ntotal=0, nproj=0;
    
        if (network_suspended) return false;
        if (file_xfers_suspended) return false;
    
    
        // limit the number of file transfers per project
        // (uploads and downloads are limited separately)
        //
        for (i=0; i<file_xfers->file_xfers.size(); i++) {
            FILE_XFER* fxp = file_xfers->file_xfers[i];
            if (pfx.is_upload == fxp->is_upload) {
                ntotal++;
                if (pfx.fip->project == fxp->fip->project) {
                    nproj++;
                }
            }
        }
        if (nproj >= config.max_file_xfers_per_project) return false;