Ignore:
Timestamp:
02/22/10 14:52:00 (14 years ago)
Author:
mmaipsl
Message:

MM, PB : try to resolve conflict if two processes are writing on some card file.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libIGCM/libIGCM_card/libIGCM_card.ksh

    r221 r223  
    190190        fi 
    191191        rm ${tmpfile} 
     192 
     193        # The tmpfile uses now the real path of the card to be modified,  
     194        # not just a local tmpfile with PID. 
     195        tmpfile=$1_$$ 
     196 
     197        # Watch for possible conflics : Check for other tmpfiles. 
     198        set -A tmpfiles -- $( ls $1_[0-9]* 2>/dev/null ) 
     199        typeset isleep 
     200        ((isleep=0)) 
     201        while [ ${#tmpfiles[@]} -gt 0 ] ; do  
     202            echo "Conflict between two processes working on " $1 "!!!" ${tmpfiles[@]} 
     203            sleep 1 
     204            ((isleep=isleep+1)) 
     205            if [ isleep -gt 20 ] ; then 
     206                echo "Too many loops wating for other process working on " $1 ". We continue." 
     207                echo "You should see if one process of your run or post-treatment may have terminated suddenly." 
     208                echo "Afer, you should erase this(those) file(s) : " ${tmpfiles[@]} 
     209# Send a mail to USER ?? 
     210                break ; 
     211            fi 
     212            set -A tmpfiles -- $( ls $1_[0-9]* 2>/dev/null ) 
     213        done 
     214 
     215        # Do the job 
    192216        ( gawk -f ${libIGCM}/libIGCM_card/IGCM_card_WriteOption.awk -- "$@" 2> /dev/null ) > ${tmpfile} 
     217 
    193218        cp $1 $1.bak 
    194219        mv ${tmpfile} $1 
     220 
    195221    else 
    196222        echo "--Error--> IGCM_card_WriteOption $@" 
Note: See TracChangeset for help on using the changeset viewer.