peer->close = 1;
return;
}
- CBREG(peer->transfer, trans_filterout, (int (*)(struct transfer *, wchar_t *, wchar_t *, void *))trresumecb, NULL, peer);
return;
}
if(supports(peer, "adcget"))
}
transfersetnick(transfer, peer->wcsname);
peer->transfer = transfer;
+ CBREG(peer->transfer, trans_filterout, (int (*)(struct transfer *, wchar_t *, wchar_t *, void *))trresumecb, NULL, peer);
if(peer->extended)
sendsupports(peer);
qstrf(sk, "$Direction %s %i|", (peer->direction == TRNSD_UP)?"Upload":"Download", rand() % 10000);
}
transfersetnick(transfer, peer->wcsname);
peer->transfer = transfer;
+ CBREG(peer->transfer, trans_filterout, (int (*)(struct transfer *, wchar_t *, wchar_t *, void *))trresumecb, NULL, peer);
qstrf(sk, "$Direction %s %i|", (peer->direction == TRNSD_UP)?"Upload":"Download", rand() % 10000);
qstrf(sk, "$Key %s|", key);
free(key);
}
if(peer->ptclose)
{
- freedcpeer(peer);
+ peer->close = 1;
} else {
if(peer->timeout == NULL)
peer->timeout = timercallback(ntime() + 180, (void (*)(int, void *))peertimeout, peer);
}
}
+static void peerdetach(struct dcpeer *peer)
+{
+ CBUNREG(peer->transfer, trans_filterout, peer);
+ closesock(peer->trpipe);
+ quitsock(peer->trpipe);
+ peer->trpipe = NULL;
+ if(peer->transfer->dir == TRNSD_UP)
+ peer->transfer->close = 1;
+ else if(peer->transfer->dir == TRNSD_DOWN)
+ resettransfer(peer->transfer);
+ peer->transfer = NULL;
+}
+
static void transread(struct socket *sk, struct dcpeer *peer)
{
void *buf;
}
if(peer->transfer->curpos >= peer->transfer->size)
{
- closesock(peer->trpipe);
- quitsock(peer->trpipe);
- peer->trpipe = NULL;
- peer->transfer = NULL;
+ peerdetach(peer);
peer->close = 1;
return;
}
freedcpeer(peer);
return;
}
- closesock(peer->trpipe);
- quitsock(peer->trpipe);
- peer->trpipe = NULL;
- peer->transfer = NULL;
+ peerdetach(peer);
peer->close = 1;
}
{
peer->state = PEER_SYNC;
dctransgotdata(peer->transfer, peer);
- CBUNREG(peer->transfer, trans_filterout, peer);
+ peerdetach(peer);
+ if(peer->state != PEER_CMD) {
+ peer->close = 1;
+ }
}
static struct socket *mktrpipe(struct dcpeer *peer)
new = smalloc(sizeof(*new));
memset(new, 0, sizeof(*new));
- new->transfer = NULL;
getsock(sk);
new->sk = sk;
if(confgetint("dc", "dcppemu"))
peer->next->prev = peer->prev;
if(peer->prev != NULL)
peer->prev->next = peer->next;
- if(peer->trpipe != NULL) {
- closesock(peer->trpipe);
- quitsock(peer->trpipe);
- }
if(peer->transfer != NULL)
- {
- CBUNREG(peer->transfer, trans_filterout, peer);
- if(peer->transfer->dir == TRNSD_UP)
- peer->transfer->close = 1;
- if(peer->transfer->dir == TRNSD_DOWN)
- resettransfer(peer->transfer);
- }
+ peerdetach(peer);
if(peer->timeout != NULL)
canceltimer(peer->timeout);
if(peer->sk->data == peer)