/* This function is the primary way for a multi/multi_socket application to figure out if a transfer has ended. We MUST make this function as fast as possible as it will be polled frequently and we MUST NOT scan any lists in here to figure out things. We must scale fine to thousands of handles and beyond. The current design is fully O(1).  */
CURLMsg* curl_multi_info_read(struct Curl_multi *multi, int *msgs_in_queue)
/* This function is the primary way for a multi/multi_socket application to figure out if a transfer has ended. We MUST make this function as fast as possible as it will be polled frequently and we MUST NOT scan any lists in here to figure out things. We must scale fine to thousands of handles and beyond. The current design is fully O(1).  */
CURLMsg* curl_multi_info_read(struct Curl_multi *multi, int *msgs_in_queue)
{
  struct Curl_message *msg;
  *msgs_in_queue = 0;
  if(GOOD_MULTI_HANDLE(multi) &&
     !multi->in_callback &&
     Curl_llist_count(&multi->msglist)) {
    struct curl_llist_element *e;
    e = multi->msglist.head;
    msg = e->ptr;
    Curl_llist_remove(&multi->msglist, e, NULL);
    *msgs_in_queue = curlx_uztosi(Curl_llist_count(&multi->msglist));
    return &msg->extmsg;
  }
  return NULL;
}