cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-library Mailing List Archives

Re: a curl_multi_fdset() replacement? (TODO-RELEASE #55)

From: Richard Atterer <richard_at_2005.atterer.net>
Date: Wed, 2 Feb 2005 22:13:16 +0100

On Wed, Feb 02, 2005 at 08:08:57PM +0100, Daniel Stenberg wrote:
> while(still_things_to_do) {
> curl_multi_sock(args...); /* get file descriptors */
> set_things_up(); /* prepare for poll/select/similar */
> select() or poll() or similar(); /* waits on 10000 connections */
> curl_multi_perform();
> }

Well, in my case ("glibcurl" glue code) it is more like:

while (glib_main_loop_running) {
  curl_multi_fdset();
  for (fd = 0; fd <= fdMax; ++fd) {
    gushort events = 0;
    if (FD_ISSET(fd, fdRead)) events |= GLIBCURL_READ;
    if (FD_ISSET(fd, fdWrite)) events |= GLIBCURL_WRITE;
    if (FD_ISSET(fd, fdExc)) events |= GLIBCURL_EXC;
    if (events == events_from_previous_main_loop_iteration[fd])
      continue;
    if (events == 0)
      g_source_remove_poll(fd);
    else
      g_source_add_poll(fd);
  }
  // glib main loop calls poll() for fds passed with g_source_*()
  curl_multi_perform();
}

Notes:
 - I need to remember the old state and check for fds that have been added
   or removed.
 - after my setting up glib's data structures from the fdsets, glib will
   internally copy the info again before calling poll() - the info is
   copied twice! :-/

> Of course curl_multi_sock() could be made to call a callback for what
> file descriptors that are added/removed from the previous call. If that
> is what people in general prefer.

As you can see from the code above, in my case it would be the nicest
solution!

Cheers,

  Richard

-- 
  __   _
  |_) /|  Richard Atterer     |  GnuPG key:
  | \/|  http://atterer.net  |  0x888354F7
   '` 
Received on 2005-02-02

These mail archives are generated by hypermail.

donate! Page updated November 12, 2010.
web site info

File upload with ASP.NET