curl / Mailing Lists / curl-library / Single Mail

curl-library

Re: can't go ahead if event isn't finished in libevent

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 2 May 2017 15:57:52 +0200 (CEST)

On Tue, 2 May 2017, Pahome Chen wrote:

Please consider not top-posting to make it easier to read this mail thread!

> *static* *void* *fifo_cb*(*int* fd, *short* event, *void* *arg)
> {
>
> ...
> *...*
> new_conn(s, arg); */* if we read a URL, go get it! */ *
> }
> *else*
> *break*;
> } *while*(rv != EOF);
>
> *while(1); *// I add this line to block the function but I already
> add easy handle to multi handle
> }

Didn't we already discuss that hyperfifo runs single-threaded and if you loop
unconditionally there then no transfer will occur?

> then *sock_cb* will never executed, the application will only execute
> *multi_timer_cb*

Rigth, since you will only add new handles to the multi handle and never
actually make them progress anywhere. That's what the fifo_cb callback does in
that example.

But why on earth do you do that while(1) loop there? The code is already
written to call that callback when there's activity on the fifo.

> I'm sure I already add easy handle and finish executing *new_conn* but
> *sock_cb* doesn't activate

Once you've added a curl handle to the multi handle, you need to call
curl_multi_socket_action() to get the transfer going. Call it indicating a
time-out. It is described in "Everything curl" here:

  https://ec.haxx.se/libcurl-drive-multi-socket.html#how-to-start-everything

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html
Received on 2017-05-02