|
1 | 1 | /* |
2 | | - Copyright (C) 2002-2012, 2014-2024 Free Software Foundation, Inc. |
| 2 | + Copyright (C) 2002-2012, 2014-2025 Free Software Foundation, Inc. |
3 | 3 | Written by Keisuke Nishida, Roger While, Simon Sobisch, Ron Norman |
4 | 4 |
|
5 | 5 | This file is part of GnuCOBOL. |
@@ -4393,19 +4393,37 @@ indexed_open (cob_file *f, char *filename, |
4393 | 4393 | } |
4394 | 4394 | isfd = isbuild ((void *)filename, (int)f->record_max, &fh->key[0], |
4395 | 4395 | vmode | ISINOUT | ISEXCLLOCK); |
4396 | | -#if 0 /* activate on later merge of locking enhancements */ |
4397 | | - f->flag_file_lock = 1; |
4398 | | -#endif |
4399 | | - if (ISERRNO == EEXIST |
| 4396 | + |
| 4397 | + if (isfd < 0) { |
| 4398 | + if (ISERRNO == EFLOCKED) { |
| 4399 | + return COB_STATUS_61_FILE_SHARING; |
| 4400 | + } |
| 4401 | + if ((ISERRNO == EEXIST || ISERRNO == EBADARG) |
4400 | 4402 | #if 1 /* CHECKME: guard added by Simon, needed ? */ |
4401 | | - && omode == ISOUTPUT |
| 4403 | + && omode == ISOUTPUT |
4402 | 4404 | #endif |
4403 | | - && isfd < 0) { |
4404 | | - /* Erase file and redo the 'isbuild' */ |
4405 | | - iserase ((void *)filename); |
4406 | | - isfd = isbuild ((void *)filename, (int)f->record_max, &fh->key[0], |
4407 | | - vmode | ISINOUT | ISEXCLLOCK); |
4408 | | -#if 0 /* activate on later merge of locking enhancements */ |
| 4405 | + ) { |
| 4406 | + /* Erase file and redo the 'isbuild' */ |
| 4407 | +#if 0 /* TODO: activate on later merge of delete enhancements */ |
| 4408 | + isam_file_delete (a, f, filename); |
| 4409 | +#else |
| 4410 | + iserase ((void *)filename); |
| 4411 | +#endif |
| 4412 | +#ifdef ISVARLEN |
| 4413 | + if (f->record_min != f->record_max) { |
| 4414 | + ISRECLEN = f->record_min; |
| 4415 | + } |
| 4416 | +#endif |
| 4417 | + ISERRNO = 0; |
| 4418 | + isfd = isbuild ((void *)filename, (int)f->record_max, &fh->key[0], vmode); |
| 4419 | +#if 0 /* TODO: activate on later merge of locking enhancements */ |
| 4420 | + f->flag_file_lock = 1; |
| 4421 | +#endif |
| 4422 | + } |
| 4423 | + /* TODO: more checks in case isfd < 0, |
| 4424 | + allowing better io status than 30 */ |
| 4425 | +#if 0 /* TODO: activate on later merge of locking enhancements */ |
| 4426 | + } else { |
4409 | 4427 | f->flag_file_lock = 1; |
4410 | 4428 | #endif |
4411 | 4429 | } |
|
0 commit comments