mirror of
https://github.com/transmission/transmission
synced 2025-02-03 04:53:27 +00:00
(trunk libT) fix event_callback() error in tr-dht.c
This commit is contained in:
parent
5a9c945dbb
commit
8f3660c334
1 changed files with 4 additions and 6 deletions
|
@ -360,24 +360,22 @@ tr_dhtAnnounce(tr_torrent *tor, tr_bool announce)
|
||||||
static void
|
static void
|
||||||
event_callback(int s, short type, void *ignore UNUSED )
|
event_callback(int s, short type, void *ignore UNUSED )
|
||||||
{
|
{
|
||||||
int rc;
|
|
||||||
time_t tosleep;
|
time_t tosleep;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
|
||||||
rc = dht_periodic(s, type == EV_READ, &tosleep, callback, NULL);
|
if( dht_periodic(s, type == EV_READ, &tosleep, callback, NULL) < 0 ) {
|
||||||
if(rc < 0) {
|
|
||||||
if(errno == EINTR) {
|
if(errno == EINTR) {
|
||||||
tosleep = 0;
|
tosleep = 0;
|
||||||
} else {
|
} else {
|
||||||
perror("dht_periodic");
|
perror("dht_periodic");
|
||||||
if(rc == EINVAL || rc == EFAULT)
|
if(errno == EINVAL || errno == EFAULT)
|
||||||
abort();
|
abort();
|
||||||
tosleep = 1;
|
tosleep = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Being slightly late is fine, and has the added benefit of adding
|
/* Being slightly late is fine,
|
||||||
some jitter. */
|
and has the added benefit of adding some jitter. */
|
||||||
tv.tv_sec = tosleep;
|
tv.tv_sec = tosleep;
|
||||||
tv.tv_usec = tr_cryptoWeakRandInt( 1000000 );
|
tv.tv_usec = tr_cryptoWeakRandInt( 1000000 );
|
||||||
event_add(&dht_event, &tv);
|
event_add(&dht_event, &tv);
|
||||||
|
|
Loading…
Reference in a new issue