cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: running_handles: less than zero ?

From: Jeff Pohlmeyer <yetanothergeek_at_gmail.com>
Date: Sun, 8 Oct 2006 07:14:38 -0500

> I believe the man page already explains that once you've
> extracted a message, it won't be returned again.

OK, I think I understand now. Maybe I'm just dense, but
I re-read the man page and I still didn't find it.

> > if ( timeout_ms <= 0 ) { return; }
Oops, of course that should be:
  if ( timeout_ms < 0 ) { return; }

> > maybe using something like a CURLMOPT_TIMEOUT_FUNCTION that
> > could be defined in the application, and invoked by the library
> > whenever it sees fit. ( Just a thought. )

> You mean a function that would be called when the
> nearest timeout "point" changes?

Something like that, I guess. A callback that would signal:
"Hey you, it's time to update your timer!"

For example:

/*in multi.h*/
typedef void (*curl_multi_timeout_callback)(CURLM *multi,
                                            long timeout_ms,
                                            void *data);

/* in example app */
void update_timeout(CURLM *multi, long timeout_ms, void *data)
{
  struct timeval timeout;
  ...
  timeout.tv_sec = timeout_ms/1000;
  timeout.tv_usec = (timeout_ms%1000)*1000;
  evtimer_add((event*)data, &timeout);
}

int main(void)
{
...
curl_multi_setopt(g.multi, CURLMOPT_TIMEOUT_FUNCTION, update_timeout);
curl_multi_setopt(g.multi, CURLMOPT_TIMEOUT_DATA, &timer_event);
...
}

Then there would only be a single reference for update_timeout,
instead of having them scattered all over the program.

> I'd say that currently we lack real-world usage of the
> curl_multi_socket() API so things such as this haven't
> been tried for real very much.

For sure, I don't expect the hiper interface to be 100% stable,
or even completely defined yet.

As a side note, once I get this demo to behave properly,
I'd like to replace the fifo with a socket listening on
127.0.0.1:8080, add some request-header parsing code, and
see if I can make a sort of "local proxy" out of it.

> > libevent can be replaced fairly easily with glib-2.x
> > I can post the code if you like

> It would of course still make a nice demo app for the examples dir!

I'd be happy to have it included, thanks!

 - Jeff
Received on 2006-10-08