Expose who is using a board when it's blocked#79
Expose who is using a board when it's blocked#79kcxt wants to merge 2 commits intolinux-msm:masterfrom
Conversation
Allow it to be accessed outside cdba-server.c Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
Keep track of who is using a board by writing $CDBA_USER to the lockfile and display it when the board is blocked. Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
| err(1, "failed to open lockfile %s", lock); | ||
|
|
||
| /* Read current user out of the lockfile if there is one */ | ||
| n = read(fd, user, sizeof(user)-1); |
There was a problem hiding this comment.
This should happen under the read-lock (so that reading doesn't collide with unfinished write call). But then we don't want to give away exclusive lock on the file. Maybe it's better to have two files: one for the lock and another one for the username.
| break; | ||
|
|
||
| warnx("board is in use, waiting..."); | ||
| warnx("board is in use by %s, waiting...", user); |
There was a problem hiding this comment.
User is not a constant, it needs to be re-read constantly when printing the message. Consider userB "stealing" the board while you are waiting for it to be freed by userA. The message will still print userA, while you should be pinging userB.
| if (write(fd, user, n) < 0) | ||
| err(1, "failed to write lockfile %s", lock); | ||
|
|
||
| warnx("board locked by %s", cdba_user); |
| } | ||
|
|
||
| /* Write our username to the lockfile */ | ||
| n = snprintf(user, sizeof(user), "%s\n", cdba_user); |
There was a problem hiding this comment.
I think skipping \n might be a better choice, it saves the code on both read and write sides.
|
@calebccff gracious ping, this still needs to be reworked. |
For peace of mind, the ability to pester said user, and to catch deadlocks.