Hallo Laurent!
Hallo Cristof!

> > I need to transfer data coming from a pipe over a UMTS link to a web server.
> > From time to time, the UMTS link goes down, and worse, it sometimes cannot
> > be reestablished. I believe that in these cases, the firmware of the UMTS 
> > stick
> > hangs, but this is just a guess. Anyhow, the only way I could get the link 
> > up and
> > running again when this happens is to reboot the whole system.
> >
> > As my application will have tried for quite a while to get the link up
> > before such drastic measures, quite some data may have accumulated in the 
> > pipe.
> > To avoid loosing that data, I need to drain the pipe to store its data
> > to a file surviving the recovery. This is the place where I just want to 
> > check if
> > there is still data in the pipe. If it is empty, I reboot.
> 
>  I must be missing something obvious here. Why don't you just do things
> sequentially ?
> 
>  cat < namedpipe > savefile ; reboot

I assume the process whose purpose is to write data into the pipe has
the write end still open but sucks in sending more data as no more
requests arrive due to dropped connection.

At it's simplicity the timeout approach is not to bad here.

... but I'm more interested in how you detect connection failure and
what are your tries for recovery. Why is it not possible to kill
(signal) the process that writes to the pipe. The termination of the
pipe write end process shall result in an pipe EOF condition which will
terminate a simple shell "read" with a false condition (status). That
is no need for an extra (busy waiting) test:

while read myvars
  do
    echo "Process the data in $myvars ..."
  done
echo "Finalize your data processing here ..."
reboot

... but best would be that write process catches the shutdown signal and
writes a specific abort/shutdown packet into the pipe before closing.
The reading end may catch that special packet and do appropriate action
(reboot system if no other chance).

while read myvars
  do
    case "$myvars" in
      '++lost_connection++' )
        echo "Do connection lost actions here ..."
        reboot
        ;;
      *)
        echo "Normal processing of $myvars data ..."
        ;;
    esac
  done
# in case of pipe eof (normal end of processing?)
echo "Do pipe EOF processing here ..."

@Cristof: If you are able to give more details of your producer and
consumer tasks in addition on the informations on what are your
recovery tries, we may be able to give you more detailed examples on
how to solve your problem.
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to