Article Listing 1 Listing 2 Listing 3 Listing 4
Listing 5 Listing 6 Listing 7 Listing 8 Listing 9
Listing 10 Listing 11 Listing 12 Listing 13 Sidebar aug2004.tar

Listing 13 return_resource()

{
    # Frees a resource by deleting the symbolic link that represents the
    # fact that the resource is currently in use. See also grab_resource.

    local FUNC_NAME=return_resource
    ${TRACE:-trace $FUNC_NAME $@}

    local semaphore=$1
    integer resource_num=$2
    integer pid=$3

    if [[ $pid = "$(get_resource_holder $semaphore $resource_num)" ]]
    then
        ${INFO:-info "Returning resource $resource_num"}
        rm -f $HOME_DIR/$semaphore/$RESOURCES_DIRNAME/$resource_num
        return $?
    else
        return 1
    fi
}