cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Re: Undocumented curl_multi_select usage

From: Massimo Lombardo <unwiredbrain_at_gmail.com>
Date: Sat, 30 May 2009 16:39:53 +0200

First of all: thank you so much Daniel.

On Fri, May 29, 2009 at 23:45, Daniel Stenberg <daniel_at_haxx.se> wrote:
> Neither the cURL project nor the PHP gives this binding the amount of love
> it needs, so it lacks. You found one point that shows.

That's is the point. That sucks, because a lot of PHP libraries
heavily rely on libcurl...

> Eddie is right. A busy-loop is never a good idea. curl_multi_select+
> curl_multi_exec is meant to fix that.

Okay. That's one step forward. :-P

> This is the PHP team's docs. I'm quite sure they will appreciate help
> though.

Yeah, yeah, I know, don't worry. :-)
I'm not pointing my finger at you PHP/CURL guys!
I was just explaining the steps that led me to fail at knowing more
about curl_multi_select

> Uh. You're talking about docs for the libcurl C API.

I'm perfectly aware of that.
But what would you have done if you didn't found any info on the PHP side?
You would have searched in the C API docs, wouldn't you?

<sarcasm>After all, PHP is just JIT-compiled C...</sarcasm>

> We also provide a tutorial like docs for the multi interface (online here:
> http://curl.haxx.se/libcurl/c/libcurl-multi.html) that describes how the
> functions are used together.

Yep, I've read that page.
The only part that deals with curl_multi_fdset (curl_multi_select in PHP) is:

QUOTE:
Your application can acquire knowledge from libcurl when it would like
to get invoked to transfer data, so that you don't have to busy-loop
and call that curl_multi_perform(3) like crazy. curl_multi_fdset(3)
offers an interface using which you can extract fd_sets from libcurl
to use in select() or poll() calls in order to get to know when the
transfers in the multi stack might need attention. This also makes it
very easy for your program to wait for input on your own private file
descriptors at the same time or perhaps timeout every now and then,
should you want that.
END QUOTE.

If I was a total newbie to libcurl, after reading that page, I still
was alone in the dark: no real-world example.
IMHO, you should add some code examples section, like you do with PHP/CURL.

> I protest against you calling this a "doh" in any sense from a libcurl
> hacker and user's perspective. From a PHP/CURL user's angle perhaps, but
> this docs is not meant for those.

That's exactly what I mean. ;-)

> If anyone provides a better example, I'll happily replace what we show
> there.

And, after all, you would not be the only happy one with that... :-)

> And again: nobody provided me with a better or alternative example for [5].

That's the big problem: we have the technology, but no instructions! :-o

>> (Where I live, we use to call four dohs in a row an epic fail, but being
>> cURL such popular and powerful, I'll call it an epic fail of an hero... :-P)
>
> I agree completely. I find it fascinating that such a well-used and widely
> known PHP extension as the PHP/CURL one has such bad docs and that so very
> few people contribute fixes and/or documentation improvements for it back to
> the PHP team.
>
> Stop waiting. Fix the problems and post your patches.

I'm not in the PHP development team, sorry.
But I'll submit a documentation bug as soon as we reach a solution.

>> So my question is: is the while loop/curl_multi_exec combo the unique
>> approach a PHP developer should use
>
> That's an approach that will keep the code busy-looping like mad until all
> transfers are complete.

And that sucks. :-(

>> If Eddie was right, how should we use curl_multi_select?
>
> He is right but I don't know how to use that function.

Damn. :-(

By the way, I've found this: http://bit.ly/vxsmm (url shortened)
Which is very similar to this: http://bugs.php.net/bug.php?id=26332

Is this one the right approach?

Thanks

-- 
Massimo Lombardo
Linux user #437712
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2009-05-30