There is a race condition in lgs_file.c, where a reply can be sent by the file handling thread at the same time as the main thread times out waiting for the reply:
while (lgs_com_data.answer_f == false) { rc = pthread_cond_timedwait( &answer_cv, &lgs_ftcom_mutex, &timeout_time); /* -> UNLOCK -> LOCK */ if (rc == ETIMEDOUT) { TRACE("Timed out before answer"); api_rc = LGSF_TIMEOUT; lgs_com_data.timeout_f = true; /* Inform thread about timeout */ goto api_exit; } else if (rc != 0) { TRACE("pthread wait Failed - %s",strerror(rc)); osaf_abort(rc); } }
When pthread_cond_timedwait() returns due a time-out in the code above, there is no check if the condition variable lgs_com_data.answer_f is true. The code should be changed to check (rc == ETIMEDOUT && lgs_com_data.answer_f == false), so that time-out handling is only performed when there is no reply.
https://sourceforge.net/p/opensaf/mailman/message/32373566/
https://sourceforge.net/p/opensaf/mailman/message/32373567/
changeset: 5319:bacc4f0b7548
tag: tip
parent: 5317:e12a2d0afdf7
user: Lennart Lund lennart.lund@ericsson.com
date: Mon May 26 13:49:32 2014 +0200
summary: log: Fix possible thread race on timeout in file api [#919]
rev: bacc4f0b75487cd79e4e2e76dabea0b83079f8dd
changeset: 5318:edc1a29443bb
branch: opensaf-4.4.x
parent: 5316:cc06765dba2a
user: Lennart Lund lennart.lund@ericsson.com
date: Mon May 26 13:49:32 2014 +0200
summary: log: Fix possible thread race on timeout in file api [#919]
rev: edc1a29443bb43baf4d24bd61a337fad3862bede
Related
Tickets:
#919