{
CBUNREG(peer->transfer, trans_filterout, peer);
CBUNREG(peer->transfer, trans_destroy, peer);
+ peer->trpipe->pnext = NULL;
closesock(peer->trpipe);
quitsock(peer->trpipe);
peer->trpipe = NULL;
return;
}
dctransgotdata(peer->transfer, peer);
+ sockread(peer->trpipe);
}
static void trpiperead(struct socket *sk, struct dcpeer *peer)
struct socket *sk;
sk = netsockpipe();
+ sk->pnext = peer->sk;
sk->data = peer;
sk->readcb = (void (*)(struct socket *, void *))trpiperead;
sk->writecb = (void (*)(struct socket *, void *))trpipewrite;
int sockfamily(struct socket *sk);
void quitsock(struct socket *sk);
void socksetdebug(struct socket *sk, int level, char *nm, ...);
+void sockread(struct socket *sk);
#endif
{
void *buf;
size_t blen;
+ off_t curpos;
if((transfer->datapipe != NULL) && (sockqueueleft(transfer->datapipe) > 0)) {
buf = sockgetinbuf(sk, &blen);
- if((transfer->endpos >= 0) && (transfer->curpos + blen > transfer->endpos))
- blen = transfer->endpos - transfer->curpos;
+ if((transfer->endpos >= 0) && (transfer->localpos + blen > transfer->endpos))
+ blen = transfer->endpos - transfer->localpos;
sockqueue(transfer->datapipe, buf, blen);
free(buf);
time(&transfer->activity);
- transfer->curpos += blen;
+ transfer->localpos += blen;
bytesupload += blen;
+ }
+ curpos = transfer->localpos - socktqueuesize(transfer->datapipe);
+ if(curpos != transfer->curpos) {
+ transfer->curpos = curpos;
CBCHAINDOCB(transfer, trans_p, transfer);
}
}
void transferprepul(struct transfer *transfer, off_t size, off_t start, off_t end, struct socket *lesk)
{
transfersetsize(transfer, size);
- transfer->curpos = start;
+ transfer->curpos = transfer->localpos = start;
transfer->endpos = end;
transfersetlocalend(transfer, lesk);
}
wchar_t *path;
uid_t owner;
int state, dir, error;
- off_t size, curpos, endpos;
+ off_t size, curpos, endpos, localpos;
struct fnetnode *fn;
struct socket *localend, *datapipe;
struct wcspair *args;