curl-library
Re: Basic usage - easy vs multi in multithreaded application
Date: Tue, 19 Sep 2006 14:59:33 -0300
On 9/15/06, Juan Manuel Lopez Baio <jmbaio_at_gmail.com> wrote:
> > To the best of my understanding you have it right. You can use the easy
> > API in a threaded environment (one handle per thread) or the multi in a
> > single-threaded environment. There's nothing wrong with either way, it's
> > a matter of personal preference.
> >
> > MB
> >
> Great! So, I started to throw some code aiming for the easy-threaded
> option, and decided to make just one call to curl_global_init and
> curl_global_cleanup from the main thread, so as to not do it every
> time I create and execute a transfer object; since those functions
> don't... <redundancy> handle handles </redundancy>, there wouldn't be
> any problem with that, right?
> I ask to prevent those psychically exhausting bughunts later on... ;)
> Thanks for the help!
>
> Juan
>
from "libcurl win32 multi-thread problem" thread:
On 9/19/06, Dan Fandrich <dan_at_coneharvesters.com> wrote:
> On Tue, Sep 19, 2006 at 05:30:09PM +0300, Razvan wrote:
> > Hello people !
> >
> > I have an multi threaded application that must upload from each thread a file
> > to an ftp server.
> > The problem is that only one thread is uploading and the speed never reaches
> > 60kb/s in the same LAN.
>
> I'm not positive I know the source of this particular problem, but the source
> code is full of errors. I'm assuming you're already doing the right thing
> to build and link with a thread-safe C library.
>
> > here is the function called from each thread:
> >
> >
> >
> > int ftp_upload(char* username, char* password, char* address, char* remote_dir,
> > char* local_file, char* upload_as )
> > {
> > FILE * hd_src ;
> > CURL* curl_handler;
> > CURLcode res;
> > char* REMOTE_URL;
> > int hd ;
> > struct stat file_info;
> >
> > char* buf_1; //[] = "RNFR " UPLOAD_FILE_AS;
> > char* buf_2; //[] = "RNTO " RENAME_FILE_TO;
> >
> > curl_global_init(CURL_GLOBAL_ALL);
>
> curl_global_init must *not* be called once from each thread--it's not thread
> safe.
Great! thanks for the help. It was a bit confusing, though, since it's
supposed to be thread-safe at one-handle per thread, and this didn't
seem to be using any handle.
> >
> > fclose(hd_src); /* close the local file */
> >
> > return res;
> > }
>
> You need to spend more time in the man pages.
I ./configuredmademadeinstalled curl (curl-7.15.5.tar.gz), and the man
pages for libcurl were not installed (curl's ones did); they would be
very useful I guess... where could I get them?
> >>> Dan
Received on 2006-09-19