cURL / Mailing Lists / curl-library / Single Mail

curl-library

libcurl in Team Fortress 2

From: Jon Lippincott <jonl_at_valvesoftware.com>
Date: Thu, 30 Jun 2011 01:43:21 +0000

Hi all,

We are using libcurl on the server-side for the TF2 replay system, and could use some help diagnosing some problems.

Without getting into too much detail<http://forums.steampowered.com/forums/showthread.php?p=22333197#post22333197>, the gist of the system is that replay-enabled servers use libcurl (7.21.2) to offload small chunks of data over FTP, every 15 seconds or so. Clients can then get at the data over HTTP.

One of the biggest issues server operators are running into is that things will be going along smoothly with no issues - uploading these chunks of data successfully - and then suddenly libcurl will error out with a "Couldn't resolve host name" message. Anyone have any clue what could be causing this?

I've pasted a simplified version of the uploading code below in case that's useful.

Thanks a bunch.

-Jon

--
size_t CFtp::ReadCallback( void *pDst, size_t nSize, size_t nCount, void *pStream )
{
       return fread( pDst, nSize, nCount, (FILE *)pStream );
}
bool CFtp::Go()
{
       // Get a curl handle
       CURL *pCurl = curl_easy_init();
       if ( !pCurl )
       {
              return false;
       }
       Assert( m_szRemotePath[0] == '/' );
       CFmtStr fmtURL(
              "ftp://%s:%i%s%s%s",
              m_szHostname, m_nPort, m_szRemotePath, V_strlen( m_szRemotePath ) == 1 ? "" : "/",
              FTP_GetFilename()
       );
       CFmtStr fmtLogin( "%s:%s", m_szLogin, m_szPassword );
       // Set up parameters
       curl_easy_setopt( pCurl, CURLOPT_URL, fmtURL.Access() );      // URL
       curl_easy_setopt( pCurl, CURLOPT_USERPWD, fmtLogin.Access() );       // Username:password
       // Get size of local file
       curl_off_t nSrcFileSize = g_pFullFileSystem->Size( m_szLocalFile );
       if( !nSrcFileSize )
       {
              return false;
       }
       // Open the local file
       m_pSrcFile = (void *)fopen( m_szLocalFile, "rb" );
       if ( !m_pSrcFile )
       {
              return false;
       }
       // Set up parameters
       curl_easy_setopt( pCurl, CURLOPT_READFUNCTION, CFtp::ReadCallback ); // Specify our read function
       curl_easy_setopt( pCurl, CURLOPT_UPLOAD, 1L );  // Enable uploading
       curl_easy_setopt( pCurl, CURLOPT_READDATA, (FILE *)m_pSrcFile );     // Specify file to upload
       curl_easy_setopt( pCurl, CURLOPT_INFILESIZE_LARGE, ( curl_off_t )nSrcFileSize );  // File size (optional)
       // Go!
       CURLcode nResult = curl_easy_perform( pCurl );
       // Cleanup
       curl_easy_cleanup( pCurl );
       return nResult == CURLE_OK;
}

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-06-30