| 1275 |
// Read lock on any specific section will also acquire single read lock on "all section" |
// Read lock on any specific section will also acquire single read lock on "all section" |
| 1276 |
// so that write lock on all section only need to acquire single write on on "all section" |
// so that write lock on all section only need to acquire single write on on "all section" |
| 1277 |
// rather than to acquire multiple write locks on all the available sections. |
// rather than to acquire multiple write locks on all the available sections. |
| 1278 |
if (index == BBS_max_section) |
if (index != BBS_max_section) |
| 1279 |
{ |
{ |
| 1280 |
sops[2].sem_num = BBS_max_section * 2 + 1; // w_sem of all section |
sops[2].sem_num = BBS_max_section * 2 + 1; // w_sem of all section |
| 1281 |
sops[2].sem_op = 0; // wait until unlocked |
sops[2].sem_op = 0; // wait until unlocked |
| 1289 |
timeout.tv_sec = wait_sec; |
timeout.tv_sec = wait_sec; |
| 1290 |
timeout.tv_nsec = 0; |
timeout.tv_nsec = 0; |
| 1291 |
|
|
| 1292 |
ret = semtimedop(section_list_pool_semid, sops, (index == BBS_max_section ? 4 : 2), &timeout); |
ret = semtimedop(section_list_pool_semid, sops, (index == BBS_max_section ? 2 : 4), &timeout); |
| 1293 |
if (ret == -1 && errno != EAGAIN && errno != EINTR) |
if (ret == -1 && errno != EAGAIN && errno != EINTR) |
| 1294 |
{ |
{ |
| 1295 |
log_error("semtimedop(index = %d, lock read) error %d\n", index, errno); |
log_error("semtimedop(index = %d, lock read) error %d\n", index, errno); |
| 1351 |
sops[0].sem_op = -1; // unlock |
sops[0].sem_op = -1; // unlock |
| 1352 |
sops[0].sem_flg = IPC_NOWAIT | SEM_UNDO; // no wait |
sops[0].sem_flg = IPC_NOWAIT | SEM_UNDO; // no wait |
| 1353 |
|
|
| 1354 |
// The same reason as section_list_try_rd_lock() |
if (index != BBS_max_section) |
|
if (index == BBS_max_section) |
|
| 1355 |
{ |
{ |
| 1356 |
sops[1].sem_num = BBS_max_section * 2; // r_sem of all section |
sops[1].sem_num = BBS_max_section * 2; // r_sem of all section |
| 1357 |
sops[1].sem_op = -1; // unlock |
sops[1].sem_op = -1; // unlock |
| 1358 |
sops[1].sem_flg = IPC_NOWAIT | SEM_UNDO; // no wait |
sops[1].sem_flg = IPC_NOWAIT | SEM_UNDO; // no wait |
| 1359 |
} |
} |
| 1360 |
|
|
| 1361 |
ret = semop(section_list_pool_semid, sops, (index == BBS_max_section ? 2 : 1)); |
ret = semop(section_list_pool_semid, sops, (index == BBS_max_section ? 1 : 2)); |
| 1362 |
if (ret == -1 && errno != EAGAIN && errno != EINTR) |
if (ret == -1 && errno != EAGAIN && errno != EINTR) |
| 1363 |
{ |
{ |
| 1364 |
log_error("semop(index = %d, unlock read) error %d\n", index, errno); |
log_error("semop(index = %d, unlock read) error %d\n", index, errno); |