curl / Mailing Lists / curl-library / Single Mail

curl-library

epoll() request drop issue

From: Tushar Pathare via curl-library <curl-library_at_cool.haxx.se>
Date: Mon, 24 Jul 2017 19:13:05 +0530

Hi Daniel,

Thank you for the reply.

I have removed curl_multi_perform() usage in epoll() implementation and
used only curl_multi_socket_action(), but still i'm seeing request drop.

Also I have reviewed my implementation for error logging, I have checked
the return value of each called libcurl library function and added error
logging. No any error observed in complete log.

The target servers are placed under the load balancer and have enough
capacity to handle generated test request load.

I have created epoll fd and multi-curl handle at thread level to make it
thread safe.

I have one more question, in epoll_wait(), when the actual data transfer
start? As per the libcurl document, we need to call curl_multi_perform (in
select()) or curl_multi_socket_action (in socket based api like epoll()) to
start data transfer. So we used curl_multi_socket_action() for epoll
implementation.
code snippet:
===========================================================
curl_multi_socket_action(multi, CURL_SOCKET_TIMEOUT, ev_bitmask,
&running_handles);
while(running_handles > 0 && waiting_time > 0) {
struct epoll_event events[MAX_EVENTS];
event_count = epoll_wait(epoll_fd, events, MAX_EVENTS, waiting_time);
if (event_count == -1) {
fprintf(stderr, "%d:ERROR epoll_wait:%d|%s\n", th_id, errno,
strerror(errno));
}else
if (event_count == 0) {
curl_multi_socket_action(multi, CURL_SOCKET_TIMEOUT, ev_bitmask,
&running_handles);
}else{
for(it = 0; it < event_count; it++) {
curl_multi_socket_action(multi, events[it].data.fd, ev_bitmask,
&running_handles);
}
}
}
============================================================
Can you please review above snippet and correct me if I'm incorrect
anywhere.

On Mon, Jul 24, 2017 at 3:30 PM, <curl-library-request_at_cool.haxx.se> wrote:

> Send curl-library mailing list submissions to
> curl-library_at_cool.haxx.se
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://cool.haxx.se/cgi-bin/mailman/listinfo/curl-library
> or, via email, send a message with subject or body 'help' to
> curl-library-request_at_cool.haxx.se
>
> You can reach the person managing the list at
> curl-library-owner_at_cool.haxx.se
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of curl-library digest..."
>
>
> Today's Topics:
>
> 1. epoll something (Re: curl-library Digest, Vol 143, Issue 18)
> (Daniel Stenberg)
> 2. Re: Issue with playback of video captured by libcurl
> (Vinod Shetty)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sun, 23 Jul 2017 17:06:23 +0200 (CEST)
> From: Daniel Stenberg <daniel_at_haxx.se>
> To: Tushar Pathare via curl-library <curl-library_at_cool.haxx.se>
> Cc: Tushar Pathare <patharetush_at_gmail.com>
> Subject: epoll something (Re: curl-library Digest, Vol 143, Issue 18)
> Message-ID: <alpine.DEB.2.20.1707231658320.1933_at_tvnag.unkk.fr>
> Content-Type: text/plain; charset=US-ASCII; format=flowed
>
> On Fri, 21 Jul 2017, Tushar Pathare via curl-library wrote:
>
> > Thank you for the response, Daniel.
>
> Please switch off digest-mode for the mailing list before trying to keep a
> conversation on it! We don't want to see you quote a busload of non-related
> messages and we prefer a mail subject that tells what the thread is about!
>
> >> What exactly happens with the failing requests? And is there a threshold
> >> somewhere when the errors start to occur?
> >
> > There is not any specific threshold for the request drop. Not getting any
> > error in the log. Can you suggest few point's where I can add logs for
> error
> > identification?
>
> libcurl returns error codes for every function and every failed request.
> You
> should check those. Unless you overload the target server(s), requests are
> not
> expected to fail at all.
>
> > Thread has following properties:
> > - one epoll fd
> > - one multi curl handle
> > - 50 HTTP request added in above multi handle.
> > - number of iterations
>
> Just make sure that you don't ever use the handles in more than one thread
> at
> a time.
>
> > If I don't add curl_multi_socket_action() after curl_multi_perform(),
> then
> > my request are not getting success(epoll_wait() get timedout and not
> getting
> > any single event). Timeout is very important in my poc. I don't want to
> wait
> > for all responses if the timeout occurs.
>
> If you want the event-based API then you should *only* use
> *multi_socket_action() and *not* *multi_perform(). Any mixed use with
> these in
> the same transfer loop will cause you unexpected behaviors and you should
> consider that a flawed program.
>
> I presume that's your biggest problem in your code. If you want to use
> epoll,
> use *multi_socket_action(). If you want to use select, use
> *multi_perform().
>
> libcurl will handle timeouts fine independently of which of these methods
> you
> pick.
>
> --
>
> / daniel.haxx.se
>
>
> ------------------------------
>
> Message: 2
> Date: Mon, 24 Jul 2017 14:31:56 +0530
> From: Vinod Shetty <vinodshetty30_at_gmail.com>
> To: Erik Janssen <erik.janssen_at_axis.com>
> Cc: libcurl development <curl-library_at_cool.haxx.se>
> Subject: Re: Issue with playback of video captured by libcurl
> Message-ID:
> <CAFSt04THbfK9a29wZ256iFZvDcDKuaTMOV8tqD51oJRCKnOL6Q_at_mail.
> gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Thank you Erik for the response.
>
> Regards,
> Vinod
>
> On Thu, Jun 29, 2017 at 1:56 PM, Erik Janssen <erik.janssen_at_axis.com>
> wrote:
>
> >
> > > I am storing the content in a <filename>.avi file.
> >
> > You can't do that. What you get is an endless HTT response that carries a
> > stream, not a file. You have to extract the payload from the HTTP
> response
> > and write in a container format yourself, upon completion you need to
> write
> > length/duration/number of frames in a proper header. Google a bit for
> > libraries to help you create .avi, .mp4 etc.
> >
> > VLC is clever and recognizes the content as a raw format and will play
> it,
> > making you think you wrote an avi-file.
> >
> > Wrt irregular playback you will need to do further research. You need a
> > container format that supports timestamps per frame (ruling out .avi).
> >
> > Erik
> >
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://cool.haxx.se/pipermail/curl-library/
> attachments/20170724/14606fd7/attachment-0001.html>
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> curl-library mailing list
> curl-library_at_cool.haxx.se
> https://cool.haxx.se/cgi-bin/mailman/listinfo/curl-library
>
>
> ------------------------------
>
> End of curl-library Digest, Vol 143, Issue 21
> *********************************************
>

-- 
Thanks & Regards,
Tushar

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