Re: Threading issue in 5.6 and 5.8
Hi Stas, here is the google groups page that defines the problem. http://groups.google.com/groups?hl=en&lr=lang_en&ie=UTF-8&threadm=7j14it%248v1%241%40zonnetje.NL.net&rnum=1&prev=/groups%3Fnum%3D100%26hl%3Den%26lr%3Dlang_en%26ie%3DISO-8859-1%26q%3DIO%253A%253ASocket%253A%253AINET%2Bmod_perl%2BWindows%2BNT%26sa%3DN%26tab%3Dwg Basically it says the following: Hello. I'm having a problem with IO::Socket::INET using Apache mod_perl. I'm using ModPerl 1.19, Perl 5.005_03 and Apache 1.3.6 on my NT system. I've included a small sample program below that demonstrates the behaviour. The basic problem I am having is as follows: The first time I get the page it works correctly. However, if I reload the page, no output is returned. But, by pressing reload repeatedly, I noticed that every 5 times, it works correctly. As if refusing to return anything wasn't bad enough, no error is given. Any suggestions would be greatly appreciated. Thanks, Mark. Here is the possible solution, which actually works: I actually just found the problem this morning. It was a server problem. An NT thing I guess. I changed the ThreadsPerChild setting to 1 in my httpd.conf file. The problem disappeared right away. --- Stas Bekman <[EMAIL PROTECTED]> wrote: > Ged Haywood wrote: > > Hi there, > > > > On Thu, 7 Aug 2003, Mustafa Tan wrote: > > > > > >>script's name is A, and I execute the same script > 20 > >>times subsequently there is no problem. But if I > >>execute B after A, and then execute A again, then > I > >>have a problem and the problem is that there is a > >>socket error. This happens only on Windows > machines. I > >>learnt that this is a common problem and that it > is > >>because of threads. Making number of threads on > apache > >>1 solves the problem > > I doubt this has anything to do with threads, > because they are serialized in > mod_perl 1.0 on windows. Do you use mod_perl 2.0? > > Most likely your problem is the usual one: global > variables persist under > mod_perl and you have to reset them before using. > For more information see: > http://perl.apache.org/docs/1.0/guide/porting.html#Global_Variables_Persistence > > In any case when reporting problems you should at > least copy-n-paste the exact > error. And follow the guidelines: > mp1: > http://perl.apache.org/docs/1.0/guide/help.html#How_to_Report_Problems > mp2: > http://perl.apache.org/docs/2.0/user/help/help.html#Reporting_Problems > > > Sorry I know prcatically nothing about running > Apache on Windows. > > Seems strange to me that anyone would do it... :) > > This is correct for mod_perl 1.0, because threads > are serialized to make > things thread-safe. > > But this is no longer valid for mod_perl 2.0. > mod_perl 2.0 on windows should > be "as good as" on any other system. > > >>Ok, here is the real question. Should I move to > 5.8 > >>and if I should, what are the general issues that > I > >>have to be careful about. One more thing is that, > can > >>I run perl 5.8 with mod_perl 1.0? Is that > possible, or > >>do I also have to move to mod_perl 2 and apache 2? > > > > > > You can run 5.8.x with mod_perl 1.x, the issue you > will most likely > > meet involves character encoding. Check the > archives of this List > > for more information. Look for "UTF-8" and/or > "locale". > > This is correct only for several RedHat linux > versions. it should be fixed in > RH9.1: > http://archive.develooper.com/[EMAIL PROTECTED]/msg97360.html > > > Version 2 of Apache/mod_perl might enable you to > address some of your > > threading problems on Windows, hopefully others > will be able to tell > > you more than I can. > > > > 73, > > Ged. > > > -- > > > __ > Stas BekmanJAm_pH --> Just Another > mod_perl Hacker > http://stason.org/ mod_perl Guide ---> > http://perl.apache.org > mailto:[EMAIL PROTECTED] http://use.perl.org > http://apacheweek.com > http://modperlbook.org http://apache.org > http://ticketmaster.com > __ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com
Threading issue in 5.6 and 5.8
Hi everybody, I have a simple script that uses POP3Client to retrieve emails. It turns out that I can run this script only once, or more if all the subsequent requests are to the same script. That is say, my script's name is A, and I execute the same script 20 times subsequently there is no problem. But if I execute B after A, and then execute A again, then I have a problem and the problem is that there is a socket error. This happens only on Windows machines. I learnt that this is a common problem and that it is because of threads. Making number of threads on apache 1 solves the problem, but then a refresh is extremely slow, cause it seems KeepAlive makes the thread stop responding to the refresh until keep alive times out. Ok, here is the real question. Should I move to 5.8 and if I should, what are the general issues that I have to be careful about. One more thing is that, can I run perl 5.8 with mod_perl 1.0? Is that possible, or do I also have to move to mod_perl 2 and apache 2? Thanks __ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com
Re: mod perl , windows/apache problem
Hi Erik, it seems that you ported a perl code from Unix to Windows. In my experience, fcntl was creating a problem in my code. That maybe the case for you too, and also post the error log messages if there is any. --- Erik Browaldh <[EMAIL PROTECTED]> wrote: > Hello everyone! > > I have written a program that takes argument from > html-formula and read and > write it to a textfile. > > When I tried it with perl mod 2, under windows with > apache it doesnt work anymore. > No new entries are written to the log-file.txt > Ive tried chmod, especially r/w accesses > but that doesnt seem to help. > > also, .cgi files is renamed as .pl and the first > line #!/usr/bin/perl -w > is deleted. > > Maybe some configurations are wrong? > More comments are followed in the code below. > Under Linux, Apache this program works > > Greatful for helps > Erik > > > > alarm(30); > $POST_MAX=5000; > use CGI::Carp qw(fatalsToBrowser); > use CGI':standard'; > use POSIX 'strftime'; > > ($Second, $Minute, $Hour, $Day, $Month, $Year, > $WeekDay, $DayOfYear, > $IsDST) = localtime(time); > > #get name and message from HTML-formular > $l_name=param('by'); # name > $l_mess=param('mess'); # message > > if ($l_name eq ""){ #nothing written in > HTML-formula? > } > else{ #otherwise write name and message last in file > #(file path is: open T,">>log-file.txt" || die "cant open T for > write $!"; > flock T,2; # write lock > print T $l_name . "\n"; #concat: > > close T; > } > > print "Content-Type:text/html\n\n"; > > > #reading from same file (ie > C:/WEB/Apache/projects/perl) > open (T," for read $!"; > flock T,1; > while ($row=){ >$tagdata=$tagdata . $row;#all txt-data inlst i en > variabel! > } > close T; > @tuples=split(/\n/,$tagdata);# split w.r.t > > > $name4=$tuples[0]; #I just want to save the last 4 > messages in the file > $name3=$tuples[1]; > $name2=$tuples[2]; > $name1=$tuples[3]; > > $tmp_nam=$tuples[4]; > > > > if($l_name eq ""){ #IF nothing is written in the > HTML-formula, THEN > $name4=$tuples[0]; #take old information > $name3=$tuples[1]; > $name2=$tuples[2]; > $name1=$tuples[3]; > } > > else{ #else "move up" information (ie only > saving last 4 entries) >$name4=$name3; >$name3=$name2; >$name2=$name1; >$name1=$tmp_nam; > } > > > # for html-document in the same directory as > perl-script, I now had to set > #the whole path, which wasnt necessary under > Linux/Apache. > open > (F," die "Cant open $!"; > flock F,1; > while ($row=){ >$row=~s//eval$1/eg; #substitution > in html-doc >print $row; > } > close F; > > > #this file also lies under > C:/WEB/Apache/projects/perl > open T,">log-file.txt" || die "cant open T for write > $!"; > flock T,2; # skrivls > print T $name4 . "\n"; > print T $name3 . "\n"; > print T $name2 . "\n"; > print T $name1 . "\n"; > close T; > > __ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com
Re: must I use mod-perl
Hi Bulba007, You should use mod_perl when and if your CGI need is more complex than a set of CGI scripts. For example you need better performance, better control of the whole process, such as authorization, authentication, etc.., you need to implement real sound web applications, etc... mod_perl is really like the next step for the perl CGI. If you want to be able to write web "applications", then use mod_perl. Otherwise, I think you are pretty much ok with CGI. --- Bulba007 <[EMAIL PROTECTED]> wrote: > When must I to use mod_perl? It is necessary? > > B. > > > __ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com
Dynamically banning hosts
Is it possible to dynamically ban IP addresses using mod_perl. Like even the first connection from the specified ip will be rejected. I know that you can do this using httpd.conf but I am wondering how to do the same dynamically while Apache is running. Also how can I cope with denial of service attacks? I know there is no general solution to this, but is there a particular technique to ease the problem. The environment is one host that serves small number of people with a very limited bandwidth. Thanks __ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com
Few Important Questions
Hi Everybody, mod_perl is a great software. Thanks for everybody who spent time on it and make it available. When you send a reply to this, can you also describe how we can help, as an individiual, to support mod_perl and people behind it financially. Now here are some of my questions. I am working on a project that will enable people, regular people, to use their computers remotely using apache and a web browser. I have various questions though. I started this with CGI, then migrated to mod_perl. However I want to bring a very general solution to the problem, so that developers can develop in any language they want. Number one issue is that, I selected perl because that's how I get started. Now I am using mod_perl for speed and various other issues. But what is the fastest solution out there. This application is supposed to run on a standalone PC, so it doesn't have to scale well, but it has to be as fast as possible. Is mod_perl the fastest solution available, other than the C of course. How does it compare to java. Second, what are my options if I want to combine mod_perl with other solutions, such as php, java and so on. One problem seem to be the session management. The second problem is that I want to be able to mix perl files with php files. For example the directory which should be handled by mod_perl should also have php files which should also run fine. Another question is that, why hosting guys avoid using mod_perl. Is it just because mod_perl is memory hungry? Finally how can I dynamically ban an ip address in mod_perl. For example, normally you can specify certain ip addresses with Allow, Deny directives. How can I do that dynamically using mod_perl. You can answer any of the above. Thanks __ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com
Problem with mod_ssl and mod_perl on Windows
Hi, I was trying to setup Apache (with mod_perl and mod_ssl) on Windows ME, and I had a weird problem. Before the problem, let me talk about more about some details. I have installed Apache from http://perl.apache.org/dist/win32-bin/. I installed the perl 5.6 version, which is perl-win32-bin.exe. THis file contains Perl 5.6 and Apache 1.3.27. It also contains mod_perl and mod_ssl. After installation I did not use the perl that the package came with. I used my ActivePerl (which is 5.6), because I already installed lots of packages there and there is no difference anyway. In my previous installation of Perl (activeperl) I had mod_perl installed, however that mod_perl was not for eapi, so I removed it and installed the one for eapi from the canadian web site. I installed mod_perl-eapi.ppd. http://theoryx5.uwinnipeg.ca/ppmpackages/ So anyway, I had mod_perl setup for perl and apache. I configured my apache so that it listens both on 443 for secure connections and 80 too. Now, let me talk about how I use mod_perl for my site. I use AuthCookieURL for authentication and authorization. What I do is essentially, get the user's name and password in a page and then authorize the user for the other pages. This works fine, until I used mod_ssl for secure connections. When I tested the apache, it works just fine for port 80. However, it doesn't work very well, on port 443. The second request to the https port crashes Apache. Now as far I as I understood the second request crashes the child process. I am not sure about the internals of Apache. What happens is that, the first request is always fine, only the second request crashes the server. The child process dies, Apache parent process creates the child process again and then everything works fine again until the next 2 requests, except of course I have to press Ok to shutdown the Apache's error box. That is the error does prevent me using Apache for secure connections. Anyway, I spent quite some time on it, and I tracked down the problem to the following. There are two problems, and let me describe how I solved the first one and how I couldn't solve the second one. The first one was that, when the user first requests a page, he/she has to login. In this phase, the AuthCookieURL module shows the custom login page. This happens by a redirection, using custom_message or something like that. I forgot its name now. Anyway, this method as you know receives a return value (in this case it is FORBIDDEN) and a messsage or a relative url. Normally it is a relative url, like /public/login.pl. This is the default way I use this module, and it normally works fine. However, in https requests the second request causes Apache crash, unless I change this method so that it actually returns the output as string. That is instead of a redirection to login.pl, I send the login page in the second argument using the custom_error method. If I make this change, Apache doesn't crash anymore. Ok, now the next step is fixing the authorization phase. Assuming that the user already supplied the correct user/password, he/she can enter to the site. However once he/she enters, the user can not make two subsequent requests without crashing the Apache. I tracked down this problem to the return value of the authorize method of AuthCookieURL. If this method returns OK, which means that the user can enter, it crashes, if the method returns DECLINED, it doesn't crash, but it certainly doesn't show anything either, cause it says "Forbidden , you don't have access" message. I couldn't fix this problem. It just seems that there is no way around this. What I found in the ssl.log is that, basically OpenSSL crashes with I/O errors. It says like expected to read 5 bytes The error somehow indicate to me that, maybe I added the modules in the wrong way. I have changed them, but again, it didn't work. That is I added mod_perl last, mod_ssl last and so on, but the net result was the same. Overall, the problem seem to be somewhat related with the phases. If anybody can help me to fix the problem, I would be thankful. Thanks __ Do you Yahoo!? Yahoo! Calendar - Free online calendar with sync to Outlook(TM). http://calendar.yahoo.com