From: Matthias Kruk Date: Sat, 19 Nov 2022 10:49:41 +0000 (+0900) Subject: include/queue: Create data file when queue is created X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=6ce1e2d8af3015b20ed89fe4f4a5c96e19644e2c;p=toolbox include/queue: Create data file when queue is created The data file that contains the queue data is not created when a queue is created, but rather when data is inserted into the queue. This causes issues in applications that use queues to share between users because they need so set permissions on the entire queue at the time of initialization. However, because the data file is not created at that time, its permissions cannot be set. This commit modifies `queue_init()' so that the data file is created together with the queue. --- diff --git a/include/queue.sh b/include/queue.sh index 0aed18d..f396689 100644 --- a/include/queue.sh +++ b/include/queue.sh @@ -142,15 +142,18 @@ queue_init() { local path local sem + local data path=$(_queue_get_path "$queue") sem=$(_queue_get_sem "$queue") + data=$(_queue_get_data "$queue") if ! mkdir "$path" &> /dev/null; then return 1 fi - if ! sem_init "$sem" 0; then + if ! sem_init "$sem" 0 || + ! touch "$data"; then rmdir "$path" &> /dev/null return 1 fi