qbittorrent / qBittorrent

qBittorrent BitTorrent client
https://www.qbittorrent.org
Other
26.99k stars 3.89k forks source link

WebAPI: FilePrio race condition #15160

Open AbeniMatteo opened 3 years ago

AbeniMatteo commented 3 years ago

Bug report

Checklist

Description

qBittorrent info

What is the problem

Calling filePrio WebAPI endpoint multiple times before the previous operation is completed overrides the previous changes.

Causes:

Detailed steps to reproduce the problem

  1. Have a torrent with files A end B, priority=0, in short (A0, B0).
  2. Call .../filePrio?hash=abc&id=0&priority=1 and wait for response. Internally reads (A0, B0) and writes (A1, B0).
  3. Call .../filePrio?hash=abc&id=1&priority=1 and wait for response. Internally reads (A0, B0) !!wrong!! and writes (A0, B1).
  4. Check file A and B priorities, should be (A1, B1) instead it's (A0, B1)
Chocobo1 commented 3 years ago

@glassez Do you think this is a libtorrent bug? if it is not then qbt needs additional workaround for it.

AbeniMatteo commented 3 years ago

I don't think so, libtorrent already has a method to merge multiple operations (see https://github.com/arvidn/libtorrent/pull/4151/files). But it only works if you request the update of specific files, qBittorrent is requesting the update of all the files and the last batch wins.

luzpaz commented 1 month ago

@AbeniMatteo is this still an issue ?