commit 2940555e6279e9c2012fbef35d7611050b6fbf4c
parent f3c677af98cd91acd61f2ff8ec1a3d2df5ee0e84
Author: sin <sin@2f30.org>
Date: Wed, 24 Sep 2014 13:07:30 +0100
Cancel pending transfers
Diffstat:
1 file changed, 11 insertions(+), 0 deletions(-)
diff --git a/ratox.c b/ratox.c
@@ -552,9 +552,12 @@ cbfiledata(Tox *m, int32_t fid, uint8_t fnum, const uint8_t *data, uint16_t len,
}
}
+/* T0D0: Might want to break this function into two separate ones for
+ * TX and RX to minimize code duplication when cancelling transfers */
static void
canceltransfer(struct friend *f)
{
+ /* Cancel TX transfers */
if (f->t.state != TRANSFER_NONE) {
printout("Cancelling transfer to %s\n",
f->namestr[0] == '\0' ? "Anonymous" : f->namestr);
@@ -566,6 +569,14 @@ canceltransfer(struct friend *f)
while (fiforead(f->dirfd, &f->fd[FFILE_IN], ffiles[FFILE_IN],
toilet, sizeof(toilet)));
}
+ /* Cancel RX transfers */
+ if (f->recvfilepending == 1) {
+ tox_file_send_control(tox, f->fid, 1, 0, TOX_FILECONTROL_KILL, NULL, 0);
+ if (f->fd[FFILE_OUT] != -1) {
+ close(f->fd[FFILE_OUT]);
+ f->fd[FFILE_OUT] = -1;
+ }
+ }
}
static void