cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Locking files, A fun but useless game

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Mon, 21 Jul 2008 20:41:02 -0700

On Sat, Jul 19, 2008 at 07:52:50AM -0700, Garabled Sdjhsjd wrote:
> I wanted to know if there was a way to lock a file.
>
> What happen is my friend challenge me on doing a quick app/hack to grab
> 'important' files that he specifies. But the catch is, he is allowed to move
> the files to dif directories while my app is trying to grab it.

Sounds like a homework assignment :^)

> The game is not really about finding the file since i can repeatly scan the
> files, check for filesize, etc. The game is grabbing the files w/o sucking up
> sucking up bandwidth.
>
> i can see all the files in the directory. Every dir has a major file to scan.
> It tells me what the important files are and which are useless + tons of other
> data to slow me down. Usually there are 25 or less files per directory. When i
> tell him i started the scan he will wait a few seconds, then move 3 file, wait
> another few seconds and move another few. a few of the important files are
> moved/renamed so i miss them. I need to grab them all w/o a rescan. I figure i
> can make his server stall the move or file rename by a request to DL of the
> file but not actually read it. Or i could do the transfer very slowly (2k per
> second? could i go slower?). I think i would need to lock the files for 80
> seconds, which is resonable? Can i prevent 24 files from being renamed/moved?
> How should i lock them? even if i cant do them all a few would be good since i
> get a better hit ratio

Once you open a file on a *NIX system, it doesn't matter if it's moved or
deleted on the server, you'll still be able to retrieve it, so your technique
should work. But you'll need to make a separate connection to the server
for each file--pipelining won't help (I'm assuming you're using HTTP). If
the server lets you open 24 connections at once you can do this, but if the
server is configured to deny that many connections to a single client, you'll
have to come up with a different way.

>>> Dan

-- 
http://www.MoveAnnouncer.com              The web change of address service
          Let webmasters know that your web site has moved
Received on 2008-07-22