Changeset 2450


Ignore:
Timestamp:
Jan 24, 2011, 4:25:19 PM (10 years ago)
Author:
schwittmann
Message:

External client: added timeout for blocking read calls

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/KeySearcher/ExternalClient/Network.cpp

    r2417 r2450  
    2525{
    2626    std::stringstream out;
    27     out << "cores:";
     27    char buf[255];
     28    if(!gethostname(buf, sizeof(buf)))
     29    {
     30        out << buf;
     31    }
     32    out << "@";
    2833    out << sysconf( _SC_NPROCESSORS_ONLN );
     34    out << "cores";
    2935    // todo: more
    3036    return out.str();
     
    6571    {
    6672        // TODO: soft break
     73        printf("Requesting new job...\n");
    6774        wrapper.WriteInt(ClientOpcodes::JOB_REQUEST);
    6875        switch(wrapper.ReadInt())
     
    8895                    {
    8996                        printf("Exception while writing results :(\n");
     97                        finishedJobs.push(res);
    9098                        throw e;
    9199                    }
     
    117125    }
    118126    printf("  Connection established\n");
     127   
     128    // set read timeout
     129    struct timeval tv;
     130    tv.tv_sec = 2*60;
     131    tv.tv_usec = 0;
     132    setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv,sizeof(struct timeval));
    119133
    120134    try{
Note: See TracChangeset for help on using the changeset viewer.