Coverage Report

Created: 2026-04-29 07:01

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/CMake/Utilities/cmcurl/lib/multi_ev.c
Line
Count
Source
1
/***************************************************************************
2
 *                                  _   _ ____  _
3
 *  Project                     ___| | | |  _ \| |
4
 *                             / __| | | | |_) | |
5
 *                            | (__| |_| |  _ <| |___
6
 *                             \___|\___/|_| \_\_____|
7
 *
8
 * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
9
 *
10
 * This software is licensed as described in the file COPYING, which
11
 * you should have received as part of this distribution. The terms
12
 * are also available at https://curl.se/docs/copyright.html.
13
 *
14
 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15
 * copies of the Software, and permit persons to whom the Software is
16
 * furnished to do so, under the terms of the COPYING file.
17
 *
18
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19
 * KIND, either express or implied.
20
 *
21
 * SPDX-License-Identifier: curl
22
 *
23
 ***************************************************************************/
24
#include "curl_setup.h"
25
26
#include "urldata.h"
27
#include "url.h"
28
#include "cfilters.h"
29
#include "curl_trc.h"
30
#include "multiif.h"
31
#include "multi_ev.h"
32
#include "select.h"
33
#include "uint-bset.h"
34
#include "uint-spbset.h"
35
#include "multihandle.h"
36
37
38
static void mev_in_callback(struct Curl_multi *multi, bool value)
39
0
{
40
0
  multi->in_callback = value;
41
0
}
42
43
/* Information about a socket for which we inform the libcurl application
44
 * what to supervise (CURL_POLL_IN/CURL_POLL_OUT/CURL_POLL_REMOVE)
45
 */
46
struct mev_sh_entry {
47
  struct uint32_spbset xfers; /* bitset of transfers `mid`s on this socket */
48
  struct connectdata *conn; /* connection using this socket or NULL */
49
  void *user_data;      /* libcurl app data via curl_multi_assign() */
50
  unsigned int action;  /* CURL_POLL_IN/CURL_POLL_OUT we last told the
51
                         * libcurl application to watch out for */
52
  unsigned int readers; /* this many transfers want to read */
53
  unsigned int writers; /* this many transfers want to write */
54
  BIT(announced);       /* this socket has been passed to the socket
55
                           callback at least once */
56
};
57
58
static size_t mev_sh_entry_hash(void *key, size_t key_length, size_t slots_num)
59
0
{
60
0
  curl_socket_t fd = *((curl_socket_t *)key);
61
0
  (void)key_length;
62
0
  return (fd % (curl_socket_t)slots_num);
63
0
}
64
65
static size_t mev_sh_entry_compare(void *k1, size_t k1_len,
66
                                   void *k2, size_t k2_len)
67
0
{
68
0
  (void)k1_len;
69
0
  (void)k2_len;
70
0
  return (*((curl_socket_t *)k1)) == (*((curl_socket_t *)k2));
71
0
}
72
73
/* sockhash entry destructor callback */
74
static void mev_sh_entry_dtor(void *freethis)
75
0
{
76
0
  struct mev_sh_entry *entry = (struct mev_sh_entry *)freethis;
77
0
  Curl_uint32_spbset_destroy(&entry->xfers);
78
0
  curlx_free(entry);
79
0
}
80
81
/* look up a given socket in the socket hash, skip invalid sockets */
82
static struct mev_sh_entry *mev_sh_entry_get(struct Curl_hash *sh,
83
                                             curl_socket_t s)
84
0
{
85
0
  if(s != CURL_SOCKET_BAD) {
86
    /* only look for proper sockets */
87
0
    return Curl_hash_pick(sh, (char *)&s, sizeof(curl_socket_t));
88
0
  }
89
0
  return NULL;
90
0
}
91
92
/* make sure this socket is present in the hash for this handle */
93
static struct mev_sh_entry *mev_sh_entry_add(struct Curl_hash *sh,
94
                                             curl_socket_t s)
95
0
{
96
0
  struct mev_sh_entry *there = mev_sh_entry_get(sh, s);
97
0
  struct mev_sh_entry *check;
98
99
0
  if(there) {
100
    /* it is present, return fine */
101
0
    return there;
102
0
  }
103
104
  /* not present, add it */
105
0
  check = curlx_calloc(1, sizeof(struct mev_sh_entry));
106
0
  if(!check)
107
0
    return NULL; /* major failure */
108
109
0
  Curl_uint32_spbset_init(&check->xfers);
110
111
  /* make/add new hash entry */
112
0
  if(!Curl_hash_add(sh, (char *)&s, sizeof(curl_socket_t), check)) {
113
0
    mev_sh_entry_dtor(check);
114
0
    return NULL; /* major failure */
115
0
  }
116
117
0
  return check; /* things are good in sockhash land */
118
0
}
119
120
/* delete the given socket entry from the hash */
121
static void mev_sh_entry_kill(struct Curl_multi *multi, curl_socket_t s)
122
0
{
123
0
  Curl_hash_delete(&multi->ev.sh_entries, (char *)&s, sizeof(curl_socket_t));
124
0
}
125
126
static size_t mev_sh_entry_user_count(struct mev_sh_entry *e)
127
0
{
128
0
  return Curl_uint32_spbset_count(&e->xfers) + (e->conn ? 1 : 0);
129
0
}
130
131
static bool mev_sh_entry_xfer_known(struct mev_sh_entry *e,
132
                                    struct Curl_easy *data)
133
0
{
134
0
  return Curl_uint32_spbset_contains(&e->xfers, data->mid);
135
0
}
136
137
static bool mev_sh_entry_conn_known(struct mev_sh_entry *e,
138
                                    struct connectdata *conn)
139
0
{
140
0
  return (e->conn == conn);
141
0
}
142
143
static bool mev_sh_entry_xfer_add(struct mev_sh_entry *e,
144
                                  struct Curl_easy *data)
145
0
{
146
   /* detect weird values */
147
0
  DEBUGASSERT(mev_sh_entry_user_count(e) < 100000);
148
0
  return Curl_uint32_spbset_add(&e->xfers, data->mid);
149
0
}
150
151
static bool mev_sh_entry_conn_add(struct mev_sh_entry *e,
152
                                  struct connectdata *conn)
153
0
{
154
   /* detect weird values */
155
0
  DEBUGASSERT(mev_sh_entry_user_count(e) < 100000);
156
0
  DEBUGASSERT(!e->conn);
157
0
  if(e->conn)
158
0
    return FALSE;
159
0
  e->conn = conn;
160
0
  return TRUE;
161
0
}
162
163
static bool mev_sh_entry_xfer_remove(struct mev_sh_entry *e,
164
                                     struct Curl_easy *data)
165
0
{
166
0
  bool present = Curl_uint32_spbset_contains(&e->xfers, data->mid);
167
0
  if(present)
168
0
    Curl_uint32_spbset_remove(&e->xfers, data->mid);
169
0
  return present;
170
0
}
171
172
static bool mev_sh_entry_conn_remove(struct mev_sh_entry *e,
173
                                     struct connectdata *conn)
174
0
{
175
0
  DEBUGASSERT(e->conn == conn);
176
0
  if(e->conn == conn) {
177
0
    e->conn = NULL;
178
0
    return TRUE;
179
0
  }
180
0
  return FALSE;
181
0
}
182
183
/* Purge any information about socket `s`.
184
 * Let the socket callback know as well when necessary */
185
static CURLMcode mev_forget_socket(struct Curl_multi *multi,
186
                                   struct Curl_easy *data,
187
                                   curl_socket_t s,
188
                                   const char *cause)
189
0
{
190
0
  struct mev_sh_entry *entry = mev_sh_entry_get(&multi->ev.sh_entries, s);
191
0
  int rc = 0;
192
193
0
  if(!entry) /* we never knew or already forgot about this socket */
194
0
    return CURLM_OK;
195
196
  /* We managed this socket before, tell the socket callback to forget it. */
197
0
  if(entry->announced && multi->socket_cb) {
198
0
    NOVERBOSE((void)cause);
199
0
    CURL_TRC_M(data, "ev %s, call(fd=%" FMT_SOCKET_T ", ev=REMOVE)", cause, s);
200
0
    mev_in_callback(multi, TRUE);
201
0
    rc = multi->socket_cb(data, s, CURL_POLL_REMOVE,
202
0
                          multi->socket_userp, entry->user_data);
203
0
    mev_in_callback(multi, FALSE);
204
0
    entry->announced = FALSE;
205
0
  }
206
207
0
  mev_sh_entry_kill(multi, s);
208
0
  if(rc == -1) {
209
0
    multi->dead = TRUE;
210
0
    return CURLM_ABORTED_BY_CALLBACK;
211
0
  }
212
0
  return CURLM_OK;
213
0
}
214
215
static CURLMcode mev_sh_entry_update(struct Curl_multi *multi,
216
                                     struct Curl_easy *data,
217
                                     struct mev_sh_entry *entry,
218
                                     curl_socket_t s,
219
                                     unsigned char last_action,
220
                                     unsigned char cur_action)
221
0
{
222
0
  int rc, comboaction;
223
224
  /* we should only be called when the callback exists */
225
0
  DEBUGASSERT(multi->socket_cb);
226
0
  if(!multi->socket_cb)
227
0
    return CURLM_OK;
228
229
  /* Transfer `data` goes from `last_action` to `cur_action` on socket `s`
230
   * with `multi->ev.sh_entries` entry `entry`. Update `entry` and trigger
231
   * `multi->socket_cb` on change, if the callback is set. */
232
0
  if(last_action == cur_action)  /* nothing from `data` changed */
233
0
    return CURLM_OK;
234
235
0
  if(last_action & CURL_POLL_IN) {
236
0
    DEBUGASSERT(entry->readers);
237
0
    if(!(cur_action & CURL_POLL_IN))
238
0
      entry->readers--;
239
0
  }
240
0
  else if(cur_action & CURL_POLL_IN)
241
0
    entry->readers++;
242
243
0
  if(last_action & CURL_POLL_OUT) {
244
0
    DEBUGASSERT(entry->writers);
245
0
    if(!(cur_action & CURL_POLL_OUT))
246
0
      entry->writers--;
247
0
  }
248
0
  else if(cur_action & CURL_POLL_OUT)
249
0
    entry->writers++;
250
251
0
  DEBUGASSERT(entry->readers <= mev_sh_entry_user_count(entry));
252
0
  DEBUGASSERT(entry->writers <= mev_sh_entry_user_count(entry));
253
0
  DEBUGASSERT(entry->writers + entry->readers);
254
255
0
  CURL_TRC_M(data, "ev update fd=%" FMT_SOCKET_T ", action '%s%s' -> '%s%s'"
256
0
             " (%d/%d r/w)", s,
257
0
             (last_action & CURL_POLL_IN) ? "IN" : "",
258
0
             (last_action & CURL_POLL_OUT) ? "OUT" : "",
259
0
             (cur_action & CURL_POLL_IN) ? "IN" : "",
260
0
             (cur_action & CURL_POLL_OUT) ? "OUT" : "",
261
0
             entry->readers, entry->writers);
262
263
0
  comboaction = (entry->writers ? CURL_POLL_OUT : 0) |
264
0
                (entry->readers ? CURL_POLL_IN : 0);
265
0
  if(((int)entry->action == comboaction)) /* nothing for socket changed */
266
0
    return CURLM_OK;
267
268
0
  CURL_TRC_M(data, "ev update call(fd=%" FMT_SOCKET_T ", ev=%s%s)",
269
0
             s, (comboaction & CURL_POLL_IN) ? "IN" : "",
270
0
             (comboaction & CURL_POLL_OUT) ? "OUT" : "");
271
0
  mev_in_callback(multi, TRUE);
272
0
  rc = multi->socket_cb(data, s, comboaction, multi->socket_userp,
273
0
                        entry->user_data);
274
0
  mev_in_callback(multi, FALSE);
275
0
  entry->announced = TRUE;
276
0
  if(rc == -1) {
277
0
    multi->dead = TRUE;
278
0
    return CURLM_ABORTED_BY_CALLBACK;
279
0
  }
280
0
  entry->action = (unsigned int)comboaction;
281
0
  return CURLM_OK;
282
0
}
283
284
static CURLMcode mev_pollset_diff(struct Curl_multi *multi,
285
                                  struct Curl_easy *data,
286
                                  struct connectdata *conn,
287
                                  struct easy_pollset *ps,
288
                                  struct easy_pollset *prev_ps)
289
0
{
290
0
  struct mev_sh_entry *entry;
291
0
  curl_socket_t s;
292
0
  unsigned int i, j;
293
0
  CURLMcode mresult;
294
295
  /* The transfer `data` reports in `ps` the sockets it is interested
296
   * in and which combination of CURL_POLL_IN/CURL_POLL_OUT it wants
297
   * to have monitored for events.
298
   * There can be more than 1 transfer interested in the same socket
299
   * and 1 transfer might be interested in more than 1 socket.
300
   * `prev_ps` is the pollset copy from the previous call here. On
301
   * the 1st call it will be empty.
302
   */
303
0
  DEBUGASSERT(ps);
304
0
  DEBUGASSERT(prev_ps);
305
306
  /* Handle changes to sockets the transfer is interested in. */
307
0
  for(i = 0; i < ps->n; i++) {
308
0
    unsigned char last_action;
309
0
    bool first_time = FALSE; /* data/conn appears first time on socket */
310
311
0
    s = ps->sockets[i];
312
    /* Have we handled this socket before? */
313
0
    entry = mev_sh_entry_get(&multi->ev.sh_entries, s);
314
0
    if(!entry) {
315
      /* new socket, add new entry */
316
0
      first_time = TRUE;
317
0
      entry = mev_sh_entry_add(&multi->ev.sh_entries, s);
318
0
      if(!entry) /* fatal */
319
0
        return CURLM_OUT_OF_MEMORY;
320
0
      CURL_TRC_M(data, "ev new entry fd=%" FMT_SOCKET_T, s);
321
0
    }
322
0
    else if(conn) {
323
0
      first_time = !mev_sh_entry_conn_known(entry, conn);
324
0
    }
325
0
    else {
326
0
      first_time = !mev_sh_entry_xfer_known(entry, data);
327
0
    }
328
329
    /* What was the previous action the transfer had regarding this socket?
330
     * If the transfer is new to the socket, disregard the information
331
     * in `last_poll`, because the socket might have been destroyed and
332
     * reopened. We would have cleared the sh_entry for that, but the socket
333
     * might still be mentioned in the hashed pollsets. */
334
0
    last_action = 0;
335
0
    if(first_time) {
336
0
      if(conn) {
337
0
        if(!mev_sh_entry_conn_add(entry, conn))
338
0
          return CURLM_OUT_OF_MEMORY;
339
0
      }
340
0
      else {
341
0
        if(!mev_sh_entry_xfer_add(entry, data))
342
0
          return CURLM_OUT_OF_MEMORY;
343
0
      }
344
0
      CURL_TRC_M(data, "ev entry fd=%" FMT_SOCKET_T ", added %s #%" FMT_OFF_T
345
0
                 ", total=%u/%d (xfer/conn)", s,
346
0
                 conn ? "connection" : "transfer",
347
0
                 conn ? conn->connection_id : data->mid,
348
0
                 Curl_uint32_spbset_count(&entry->xfers),
349
0
                 entry->conn ? 1 : 0);
350
0
    }
351
0
    else {
352
0
      for(j = 0; j < prev_ps->n; j++) {
353
0
        if(s == prev_ps->sockets[j]) {
354
0
          last_action = prev_ps->actions[j];
355
0
          break;
356
0
        }
357
0
      }
358
0
    }
359
    /* track readers/writers changes and report to socket callback */
360
0
    mresult = mev_sh_entry_update(multi, data, entry, s,
361
0
                                  last_action, ps->actions[i]);
362
0
    if(mresult)
363
0
      return mresult;
364
0
  }
365
366
  /* Handle changes to sockets the transfer is NO LONGER interested in. */
367
0
  for(i = 0; i < prev_ps->n; i++) {
368
0
    bool stillused = FALSE;
369
370
0
    s = prev_ps->sockets[i];
371
0
    for(j = 0; j < ps->n; j++) {
372
0
      if(s == ps->sockets[j]) {
373
        /* socket is still supervised */
374
0
        stillused = TRUE;
375
0
        break;
376
0
      }
377
0
    }
378
0
    if(stillused)
379
0
      continue;
380
381
0
    entry = mev_sh_entry_get(&multi->ev.sh_entries, s);
382
    /* if entry does not exist, we were either never told about it or
383
     * have already cleaned up this socket via Curl_multi_ev_socket_done().
384
     * In other words: this is perfectly normal */
385
0
    if(!entry)
386
0
      continue;
387
388
0
    if(conn && !mev_sh_entry_conn_remove(entry, conn)) {
389
      /* `conn` says in `prev_ps` that it had been using a socket,
390
       * but `conn` has not been registered for it.
391
       * This should not happen if our book-keeping is correct? */
392
0
      CURL_TRC_M(data, "ev entry fd=%" FMT_SOCKET_T ", conn lost "
393
0
                 "interest but is not registered", s);
394
0
      DEBUGASSERT(NULL);
395
0
      continue;
396
0
    }
397
398
0
    if(!conn && !mev_sh_entry_xfer_remove(entry, data)) {
399
      /* `data` says in `prev_ps` that it had been using a socket,
400
       * but `data` has not been registered for it.
401
       * This should not happen if our book-keeping is correct? */
402
0
      CURL_TRC_M(data, "ev entry fd=%" FMT_SOCKET_T ", transfer lost "
403
0
                 "interest but is not registered", s);
404
0
      DEBUGASSERT(NULL);
405
0
      continue;
406
0
    }
407
408
0
    if(mev_sh_entry_user_count(entry)) {
409
      /* track readers/writers changes and report to socket callback */
410
0
      mresult = mev_sh_entry_update(multi, data, entry, s,
411
0
                                    prev_ps->actions[i], 0);
412
0
      if(mresult)
413
0
        return mresult;
414
0
      CURL_TRC_M(data, "ev entry fd=%" FMT_SOCKET_T ", removed transfer, "
415
0
                 "total=%u/%d (xfer/conn)", s,
416
0
                 Curl_uint32_spbset_count(&entry->xfers),
417
0
                 entry->conn ? 1 : 0);
418
0
    }
419
0
    else {
420
0
      mresult = mev_forget_socket(multi, data, s, "last user gone");
421
0
      if(mresult)
422
0
        return mresult;
423
0
    }
424
0
  } /* for loop over num */
425
426
  /* Remember for next time */
427
0
  Curl_pollset_move(prev_ps, ps);
428
0
  return CURLM_OK;
429
0
}
430
431
static void mev_pollset_dtor(void *key, size_t klen, void *entry)
432
0
{
433
0
  struct easy_pollset *ps = entry;
434
0
  (void)key;
435
0
  (void)klen;
436
0
  if(ps) {
437
0
    Curl_pollset_cleanup(ps);
438
0
    curlx_free(ps);
439
0
  }
440
0
}
441
442
static struct easy_pollset *mev_add_new_conn_pollset(struct connectdata *conn)
443
0
{
444
0
  struct easy_pollset *ps;
445
446
0
  ps = Curl_pollset_create();
447
0
  if(!ps)
448
0
    return NULL;
449
0
  if(Curl_conn_meta_set(conn, CURL_META_MEV_POLLSET, ps, mev_pollset_dtor))
450
0
    return NULL;
451
0
  return ps;
452
0
}
453
454
static struct easy_pollset *mev_add_new_xfer_pollset(struct Curl_easy *data)
455
0
{
456
0
  struct easy_pollset *ps;
457
458
0
  ps = Curl_pollset_create();
459
0
  if(!ps)
460
0
    return NULL;
461
0
  if(Curl_meta_set(data, CURL_META_MEV_POLLSET, ps, mev_pollset_dtor))
462
0
    return NULL;
463
0
  return ps;
464
0
}
465
466
static struct easy_pollset *mev_get_last_pollset(struct Curl_easy *data,
467
                                                 struct connectdata *conn)
468
0
{
469
0
  if(data) {
470
0
    if(conn)
471
0
      return Curl_conn_meta_get(conn, CURL_META_MEV_POLLSET);
472
0
    return Curl_meta_get(data, CURL_META_MEV_POLLSET);
473
0
  }
474
0
  return NULL;
475
0
}
476
477
static CURLMcode mev_assess(struct Curl_multi *multi,
478
                            struct Curl_easy *data,
479
                            struct connectdata *conn)
480
0
{
481
0
  struct easy_pollset ps, *last_ps;
482
0
  CURLMcode mresult = CURLM_OK;
483
484
0
  if(!multi || !multi->socket_cb)
485
0
    return CURLM_OK;
486
487
0
  Curl_pollset_init(&ps);
488
0
  if(conn) {
489
0
    CURLcode r = Curl_conn_adjust_pollset(data, conn, &ps);
490
0
    if(r) {
491
0
      mresult = (r == CURLE_OUT_OF_MEMORY) ?
492
0
        CURLM_OUT_OF_MEMORY : CURLM_INTERNAL_ERROR;
493
0
      goto out;
494
0
    }
495
0
  }
496
0
  else
497
0
    Curl_multi_pollset(data, &ps);
498
0
  last_ps = mev_get_last_pollset(data, conn);
499
500
0
  if(!last_ps && ps.n) {
501
0
    if(conn)
502
0
      last_ps = mev_add_new_conn_pollset(conn);
503
0
    else
504
0
      last_ps = mev_add_new_xfer_pollset(data);
505
0
    if(!last_ps) {
506
0
      mresult = CURLM_OUT_OF_MEMORY;
507
0
      goto out;
508
0
    }
509
0
  }
510
511
0
  if(last_ps)
512
0
    mresult = mev_pollset_diff(multi, data, conn, &ps, last_ps);
513
0
  else
514
0
    DEBUGASSERT(!ps.n);
515
0
out:
516
0
  Curl_pollset_cleanup(&ps);
517
0
  return mresult;
518
0
}
519
520
CURLMcode Curl_multi_ev_assess_xfer(struct Curl_multi *multi,
521
                                    struct Curl_easy *data)
522
0
{
523
0
  return mev_assess(multi, data, NULL);
524
0
}
525
526
CURLMcode Curl_multi_ev_assess_conn(struct Curl_multi *multi,
527
                                    struct Curl_easy *data,
528
                                    struct connectdata *conn)
529
0
{
530
0
  return mev_assess(multi, data, conn);
531
0
}
532
533
CURLMcode Curl_multi_ev_assess_xfer_bset(struct Curl_multi *multi,
534
                                         struct uint32_bset *set)
535
0
{
536
0
  uint32_t mid;
537
0
  CURLMcode mresult = CURLM_OK;
538
539
0
  if(multi && multi->socket_cb && Curl_uint32_bset_first(set, &mid)) {
540
0
    do {
541
0
      struct Curl_easy *data = Curl_multi_get_easy(multi, mid);
542
0
      if(data) {
543
0
        mresult = Curl_multi_ev_assess_xfer(multi, data);
544
0
      }
545
0
    } while(!mresult && Curl_uint32_bset_next(set, mid, &mid));
546
0
  }
547
0
  return mresult;
548
0
}
549
550
CURLMcode Curl_multi_ev_assign(struct Curl_multi *multi,
551
                               curl_socket_t s,
552
                               void *user_data)
553
0
{
554
0
  struct mev_sh_entry *e = mev_sh_entry_get(&multi->ev.sh_entries, s);
555
0
  if(!e)
556
0
    return CURLM_BAD_SOCKET;
557
0
  e->user_data = user_data;
558
0
  return CURLM_OK;
559
0
}
560
561
void Curl_multi_ev_dirty_xfers(struct Curl_multi *multi,
562
                               curl_socket_t s)
563
0
{
564
0
  struct mev_sh_entry *entry;
565
566
0
  DEBUGASSERT(s != CURL_SOCKET_TIMEOUT);
567
0
  entry = mev_sh_entry_get(&multi->ev.sh_entries, s);
568
569
  /* Unmatched socket, we cannot act on it but we ignore this fact. In
570
     real-world tests it has been proved that libevent can in fact give
571
     the application actions even though the socket was previously
572
     asked to get removed, so thus we better survive stray socket actions
573
     and move on. */
574
0
  if(entry) {
575
0
    struct Curl_easy *data;
576
0
    uint32_t mid;
577
578
0
    if(Curl_uint32_spbset_first(&entry->xfers, &mid)) {
579
0
      do {
580
0
        data = Curl_multi_get_easy(multi, mid);
581
0
        if(data) {
582
0
          Curl_multi_mark_dirty(data);
583
0
        }
584
0
        else {
585
0
          CURL_TRC_M(multi->admin, "socket transfer %u no longer found", mid);
586
0
          Curl_uint32_spbset_remove(&entry->xfers, mid);
587
0
        }
588
0
      } while(Curl_uint32_spbset_next(&entry->xfers, mid, &mid));
589
0
    }
590
591
0
    if(entry->conn)
592
0
      Curl_multi_mark_dirty(multi->admin);
593
0
  }
594
0
}
595
596
void Curl_multi_ev_socket_done(struct Curl_multi *multi,
597
                               struct Curl_easy *data, curl_socket_t s)
598
0
{
599
0
  mev_forget_socket(multi, data, s, "socket done");
600
0
}
601
602
void Curl_multi_ev_xfer_done(struct Curl_multi *multi,
603
                             struct Curl_easy *data)
604
0
{
605
0
  DEBUGASSERT(!data->conn); /* transfer should have been detached */
606
0
  if(data != multi->admin) {
607
0
    (void)mev_assess(multi, data, NULL);
608
0
    Curl_meta_remove(data, CURL_META_MEV_POLLSET);
609
0
  }
610
0
}
611
612
void Curl_multi_ev_conn_done(struct Curl_multi *multi,
613
                             struct Curl_easy *data,
614
                             struct connectdata *conn)
615
0
{
616
0
  (void)mev_assess(multi, data, conn);
617
0
  Curl_conn_meta_remove(conn, CURL_META_MEV_POLLSET);
618
0
}
619
620
void Curl_multi_ev_init(struct Curl_multi *multi, size_t hashsize)
621
0
{
622
0
  Curl_hash_init(&multi->ev.sh_entries, hashsize, mev_sh_entry_hash,
623
0
                 mev_sh_entry_compare, mev_sh_entry_dtor);
624
0
}
625
626
void Curl_multi_ev_cleanup(struct Curl_multi *multi)
627
0
{
628
0
  Curl_hash_destroy(&multi->ev.sh_entries);
629
0
}