light: workaround race between remote deletion and local use

This commit is contained in:
Thomas Schoebel-Theuer 2013-01-05 06:27:26 +01:00
parent 531e4def99
commit db06f20a05
1 changed files with 7 additions and 0 deletions

View File

@ -3073,12 +3073,19 @@ static int prepare_delete(void *buf, struct mars_dent *dent)
struct mars_dent *target;
struct mars_dent *response;
const char *response_path = NULL;
struct mars_brick *brick;
int max_serial = 0;
if (!global || !dent || !dent->new_link || !dent->d_path) {
goto done;
}
brick = mars_find_brick(global, NULL, dent->new_link);
if (brick && unlikely(brick->nr_outputs > 0 && brick->outputs[0] && brick->outputs[0]->nr_connected)) {
MARS_WRN("target '%s' cannot be deleted, its brick '%s' in use\n", dent->new_link, SAFE_STR(brick->brick_name));
goto done;
}
target = _mars_find_dent(global, dent->new_link);
if (target) {
mars_unlink(dent->new_link);