Ignore:
Timestamp:
Feb 18, 2011, 12:24:18 AM (11 years ago)
Author:
jch
Message:

Add dummy UTP callbacks.

Libutp will sometimes call our callbacks after we called UTP_Close,
notably to notify us of the UTP_STATE_DESTROYING state change, but
also, for some reason, to ask us about our read buffer. The simplest
way to avoid issues with that is to switch to a second set of callbacks.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peer-io.c

    r11909 r11910  
    435435};
    436436
     437/* Dummy UTP callbacks. */
     438/* We switch a UTP socket to use these after the associated peerIo has been
     439   destroyed -- see io_dtor. */
     440
     441static void
     442dummy_read(void *closure, const unsigned char *buf, size_t buflen)
     443{
     444    abort();
     445}
     446
     447static void
     448dummy_write(void *closure, unsigned char *buf, size_t buflen)
     449{
     450    abort();
     451}
     452
     453static size_t
     454dummy_get_rb_size(void *closure)
     455{
     456    return 0;
     457}
     458
     459static void
     460dummy_on_state_change(void *closure, int state)
     461{
     462    return;
     463}
     464
     465static void
     466dummy_on_error(void *closure, int errcode)
     467{
     468    return;
     469}
     470
     471static void
     472dummy_on_overhead(void *closure, bool send, size_t count, int type)
     473{
     474}
     475
     476static struct UTPFunctionTable dummy_utp_function_table = {
     477    .on_read = dummy_read,
     478    .on_write = dummy_write,
     479    .get_rb_size = dummy_get_rb_size,
     480    .on_state = dummy_on_state_change,
     481    .on_error = dummy_on_error,
     482    .on_overhead = dummy_on_overhead
     483};
     484
    437485static tr_peerIo*
    438486tr_peerIoNew( tr_session       * session,
     
    635683    if( io->utp_socket != NULL ) {
    636684        tr_ndbg( "UTP", "Destroying connection");
     685        UTP_SetCallbacks( io->utp_socket,
     686                          &dummy_utp_function_table,
     687                          NULL );
    637688        UTP_Close( io->utp_socket );
    638689    }
Note: See TracChangeset for help on using the changeset viewer.