forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Hanging in libcurl

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
AnonymousTipster



Joined: 01 Jul 2005
Posts: 197

PostPosted: Wed Aug 23, 2006 5:53 am    Post subject: Hanging in libcurl Reply with quote

I'm currently using libcurl to do some form submitting to a .php script periodically. This is done every minute in the game to keep the serverlist up to date. Usually this works fine, and there's a slight pause (0.5seconds) when uploading the data.
Sometimes however, it hangs indefinitely. This happens when you go out of reach of your router. Because the libcurl is in the same thread as the game, the game effectively freezes. I would move libcurl to another thread, but that thread would still end up hanging whenever you go out of range, so wouldn't update again.
This is the code i'm using:
Code:
   struct curl_httppost *formpost=NULL;
          struct curl_httppost *lastptr=NULL;
         curl_slist* responseHeaders = NULL ;
            curl = curl_easy_init();
            if(curl)
            {
            //add items to the form
            curl_formadd(&formpost, &lastptr,CURLFORM_COPYNAME, "Name",CURLFORM_COPYCONTENTS, myServerName,CURLFORM_CONTENTSLENGTH, strlen(myServerName), CURLFORM_END);
            curl_formadd(&formpost, &lastptr,CURLFORM_COPYNAME, "Location",CURLFORM_COPYCONTENTS, myServerLocation,CURLFORM_CONTENTSLENGTH, strlen(myServerLocation), CURLFORM_END);
            curl_formadd(&formpost, &lastptr,CURLFORM_COPYNAME, "NumberPlayers",CURLFORM_COPYCONTENTS, myServerNumberPlayersString,CURLFORM_CONTENTSLENGTH, strlen(myServerNumberPlayersString), CURLFORM_END);
            curl_formadd(&formpost, &lastptr,CURLFORM_COPYNAME, "MaxPlayers",CURLFORM_COPYCONTENTS,myServerMaxPlayersString,CURLFORM_CONTENTSLENGTH, strlen(myServerMaxPlayersString), CURLFORM_END);
                        //set url
                curl_easy_setopt(curl, CURLOPT_URL, "http://www.mywebspace.com/script.php");
            curl_easy_setopt(curl, CURLOPT_TIMEOUT, 2);
            
            curl_easy_setopt( curl , CURLOPT_HTTPPOST , formpost);
                //tell curl to actually get the page etc etc
                res = curl_easy_perform(curl);
                // always cleanup
                curl_easy_cleanup(curl);
            curl_formfree(formpost);
            //curl_slist_free_all (responseHeaders);
            }

I've also tried adding the following curl_opts to no avail:
Code:

curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 2);
            curl_easy_setopt(curl, CURLOPT_FTP_RESPONSE_TIMEOUT, 2);
            curl_easy_setopt(curl, CURLOPT_TCP_NODELAY, 1);
            curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
            curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 2);
            curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 2);
            curl_easy_setopt(curl, CURLOPT_FRESH_CONNECT, 1);
            curl_easy_setopt(curl, CURLOPT_FORBID_REUSE, 1);


I'm assuming that libcurl uses blocking sockets, might this require a source change in the library?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group