From 33e44ed6bef2adc7dbad9ec48d011297a4ed84dc Mon Sep 17 00:00:00 2001 From: Jeremy Lakeman Date: Tue, 4 Dec 2012 16:30:01 +1030 Subject: [PATCH] Don't unwatch if the file descriptor is already closed --- rhizome_fetch.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rhizome_fetch.c b/rhizome_fetch.c index dbc9557c..5f0be4c5 100644 --- a/rhizome_fetch.c +++ b/rhizome_fetch.c @@ -982,8 +982,10 @@ static int rhizome_fetch_close(struct rhizome_fetch_slot *slot) /* close socket and stop watching it */ unschedule(&slot->alarm); - unwatch(&slot->alarm); - close(slot->alarm.poll.fd); + if (slot->alarm.poll.fd>=0){ + unwatch(&slot->alarm); + close(slot->alarm.poll.fd); + } slot->alarm.poll.fd = -1; slot->alarm.function=NULL;