Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 07-24-2002, 09:10 AM   #1
HQ
Confirmed User
 
Join Date: Jan 2001
Posts: 3,539
Optimized redirection (cgi/perl)

Here's a simple redirection perl script:

Code:
#!/usr/bin/perl -wT
print "Location:http://www.nba.com/\n\n ";
sleep(15);
exit;
If you run it, you will notice that it waits 15 seconds before going to nba.com, even though nothing else is required to be 'printed' to the browser. The sleep is stuck in there to represent tracker calculations that have to be perform.

Is there anyway to cause the redirect to take place immediately, and then perform the calculations afterwards?
HQ is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 07-24-2002, 09:35 AM   #2
Babaganoosh
♥♥♥ Likes Hugs ♥♥♥
 
Babaganoosh's Avatar
 
Industry Role:
Join Date: Nov 2001
Location: /home
Posts: 15,841
Not efficiently. The only way I can think of to do something like that is to fork() a process off and do the calculations there, but I absolutely would not do that unless it is absolutely necessary. Hopefully though, your code is smooth enough to do the calculations before the user is forwarded. Simple mathematic calculations should be carried out in a fraction of a second. The user shouldn't get impatient and close the browser in that .10 of a second.
Babaganoosh is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 07-24-2002, 12:44 PM   #3
mike503
Confirmed User
 
Industry Role:
Join Date: May 2002
Location: oregon.
Posts: 2,243
uh yeah. you should be able to do all the processing before and then fire off the location header..

if you're doing that complicated of processding you may need to move to either real-time analysis (not real-time calculation) or go with a batch approach (i.e. cronjob every x minutes.)
__________________
php/mysql guru. hosting, coding, all that jazz.
mike503 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 07-24-2002, 05:04 PM   #4
NetRodent
Confirmed User
 
Join Date: Jan 2002
Location: In the walls of your house.
Posts: 3,985
Try using the following code...

Code:
#!/usr/bin/perl -wT
$| = 1;
print "Location:http://www.nba.com/\n\n ";
sleep(15);
exit;
The $| variable controls how perl buffers output. Setting
it to 1 tells it not to buffer anything but output immediately.
In general its a bad idea not to buffer but this will redirect
immediately.
NetRodent is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 07-24-2002, 05:10 PM   #5
[Labret]
Registered User
 
Industry Role:
Join Date: May 2001
Location: Са́нкт-Петербу́рг
Posts: 10,945
You randomization layers are too low.

Add a couple of glitch targeting mechanisms in order to better bedunktify the layering effect caused by the circumpreferential treatment of African Americans. fo shizzy.
[Labret] is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 07-24-2002, 06:58 PM   #6
Phil21
Confirmed User
 
Join Date: May 2001
Location: ICQ: 25285313
Posts: 993
what netrodent said should work well.

-Phil
Phil21 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 07-25-2002, 11:45 AM   #7
HQ
Confirmed User
 
Join Date: Jan 2001
Posts: 3,539
Labert, what?

NetRodent, cool i'll try that. When the script in question is only going to output a redirect (one line of text), then 'turning off' the buffer should not be a problem. Damn, I never knew there was a buffer, this is why I was confused by the waiting.

mik503, I do batch processing. I'm creating a tracker which logs raw data and it gets processed every update of the site. However, sending hits out and tracking hits in has to be accomplished in real time. The only calculations are updates to these real-time tables that stores url info, hits in, hits out, clicks produced, and where every IP has gone so I don't send it back to the same place twice. The calculations should be quick, but some of these are calculations that can be performed AFTER the destination is known (for permanent links). For blind links, the calcuations have to be performed beforehand.

Armed & Hammered, I thought of performing a fork too, but NetRodent's idea is the best solution I think.

Thanks all.
HQ is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 07-25-2002, 11:47 AM   #8
HQ
Confirmed User
 
Join Date: Jan 2001
Posts: 3,539
Quote:
Originally posted by NetRodent
The $| variable controls how perl buffers output. Setting
it to 1 tells it not to buffer anything but output immediately.
In general its a bad idea not to buffer but this will redirect
immediately.
One question. Does the $| variable change the buffer of outputs to files too? As my redirect script will be modifying files (which means it will be outputing their full contents).
HQ is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 07-25-2002, 01:31 PM   #9
NetRodent
Confirmed User
 
Join Date: Jan 2002
Location: In the walls of your house.
Posts: 3,985
Here's what the perl documentation has to say about the $| variable at http://www.perldoc.com/perl5.6/pod/perlvar.html

Quote:
autoflush HANDLE EXPR
$OUTPUT_AUTOFLUSH
$|
If set to nonzero, forces a flush right away and after every write or print on the currently selected output channel. Default is 0 (regardless of whether the channel is really buffered by the system or not; $| tells you only whether you've asked Perl explicitly to flush after each write). STDOUT will typically be line buffered if output is to the terminal and block buffered otherwise. Setting this variable is useful primarily when you are outputting to a pipe or socket, such as when you are running a Perl program under rsh and want to see the output as it's happening. This has no effect on input buffering. See perlfunc/getc for that. (Mnemonic: when you want your pipes to be piping hot.)
So to answer your question, setting the $| changes the buffering on all output including files. Of course you can do something like
this:

Code:
#!/usr/bin/perl -wT
$| = 1; # unbuffer this
print "Location:http://www.nba.com/\n\n ";
$| = 0; # buffer everything else
open(LOG, ">>log");
print LOG "blah blah blah\n";
close LOG;
exit;
It also appears that you may be able to set the buffering on particular output channels. Try reading the perl IO faqhere.
NetRodent is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 07-25-2002, 03:13 PM   #10
HQ
Confirmed User
 
Join Date: Jan 2001
Posts: 3,539
$|=1; made the redirection work faster but it was messing up my file writing (I did a $|=0; right after the redirect). Very strange. No scripting errors or anything, just that the file wasn't being written to where it was before.
HQ is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.