]> git.corax.cc Git - toolbox/commitdiff
include/queue: Create data file when queue is created
authorMatthias Kruk <m@m10k.eu>
Sat, 19 Nov 2022 10:49:41 +0000 (19:49 +0900)
committerMatthias Kruk <m@m10k.eu>
Sat, 19 Nov 2022 10:49:41 +0000 (19:49 +0900)
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.

include/queue.sh

index 0aed18d97e63969eb67296cdb4de2e04072f9659..f396689eec43e7399395c33cfe42b07556a6965e 100644 (file)
@@ -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