Re: Unuse modules

2005-11-02 Thread Matt S Trout
On Wed, Nov 02, 2005 at 03:39:18PM +0100, Kaare Rasmussen wrote:
 Yes, but if they use XS code it is quite unlikely you can get rid of  
 that.
 
 How would you remove a module? And why is XS a problem? 

Dynamically unloading shared libraries etc. is at least as hard as it looks.

 Not reliably. But then again, you shouldn't leak.
 
 Not leaking. But maybe running fat modules. Do you have any info about how 
 to do it? 

Have a look at the way Apache::Reload, Module::Refresh et. al. do it (and
have a quick nose round CPAN, there's at least a couple others).

-- 
 Matt S Trout   Specialists in Perl consulting, web development, and
  Technical DirectorUNIX/Linux systems architecture and automation. Mail
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

 + Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +


Re: Problem with sessions

2005-11-02 Thread Matt S Trout
On Wed, Nov 02, 2005 at 10:10:47AM -0800, Gil Vidals wrote:
 I'm hoping someone can point me in the right direction. I'm stuck on
 figuring out how to handle the situation where session A initiates a TCP
 client session B; however, by the time TCP session B is ready to do it's
 thing, session A is way ahead and session B is now lost without the data
 from session A. 

How about having session A store the data into a buffer as it reads it,
and then when session B's started is says to session A I'm ready now, give
me the contents of the buffer and start sending me stuff in real time ?

-- 
 Matt S Trout   Specialists in Perl consulting, web development, and
  Technical DirectorUNIX/Linux systems architecture and automation. Mail
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

 + Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +


Re: Perl2Exe and POE on Linux

2005-09-30 Thread Matt S Trout
On Fri, Sep 30, 2005 at 03:21:51PM -0500, Scott Neibarger wrote:
 Greetings,
 
 I downloaded the latest version of Perl2Exe for Linux and installed POE into
 its Perl 5.8.7 bundle.
 I've been able to get standalone Perl scripts with POE to work with the Perl
 bundle.
 However, if I build the executable, it dumps a segmentation fault with no
 core.

First, try strace :)

Second, the no core thing is a Dead Rat default. You should be able to
get core files dumped somehow (but I forget the incantation).

 I was wondering if POE has been validated to work on RedHat Linux with
 Perl2Exe?
 I've made it work with Win32, but will also need to make it work on HP-UX,
 AIX and Solaris.
 
 Best Regards,
 
 Scott Neibarger

-- 
 Matt S Trout   Specialists in perl consulting, web development, and
  Technical DirectorUNIX/Linux systems architecture and automation. Mail
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

 + Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +


Re: Wheel::Run and Proc::Daemon troubles

2005-09-08 Thread Matt S Trout
On Thu, Sep 08, 2005 at 01:32:34PM -0700, Rob Bloodgood wrote:
 Hicks, Matthew wrote:
 Honestly, from here it looks like you're either doing it 
 wrong, or there
 is an issue I'm quite ignorant of (VERY possible :).  But if 
 all you're
 trying to process is tail(1), then use POE::Wheel::FollowTail and
 hopefully you'll sidestep the problem.
  
  
  I started with POE::Wheel::FollowTail and it worked great both
  interactively and as a daemon, but scope creep soon had my 'quickie
  script' writing to a database and watching files across firewalls via
  SSH.  (Anyone got a suggestion other than using SSH+tail to watch a
  restricted access remote file?)
 
 YES.  I did it with inetd and a script I was dealing with.  My POE
 script opened SSH using Wheel::Run, and told ssh to do this loop:
 while :; do uptime; sleep 3; done
 
 If my script exited, the SSH would stay behind!

That's because POE::Wheel::Run does a setsid by default. I ran into this
issue ages back and submitted a patch which eventually made it into trunk -

NoSetSid

When true, NoSetSid disables setsid() in the child process. By default, 
setsid() is called to execute the child process in a separate Unix session.

Ta-dah! Your POE::Wheel::Run child processes will be reaped on parent exit :)

-- 
 Matt S Trout   Specialists in perl consulting, web development, and
  Technical DirectorUNIX/Linux systems architecture and automation. Mail
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

 + Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +


Re: namespace request - PoCo::Server::MDP

2005-08-27 Thread Matt S Trout
On Sat, Aug 27, 2005 at 05:16:06PM -0400, Rocco Caputo wrote:
 On Aug 26, 2005, at 16:27, Jeff Lowrey wrote:
 
 I'm in what I hope is final testing before releasing a public beta  
 of a set of modules that act as POE components to provide Message  
 Driven Perl services - in the vein of a JMS provider.
 
 The intent is that someone will be able to do something similar to
 #
 use POE;
 use POE::Component::Server::MDP::POEQueueProvider;
 
 Wow, that's long, and Provider seems to overlap with Server.   
 POE::Component::MDP::QueueProvider still has some length to it, but  
 it sounds a lot less redundant.  I assume there will be a lot of  
 modules below POE::Component::MDP.

POE::Server::MessageBus
POE::Component::MessageBus::Client

?

-- 
 Matt S Trout   Specialists in perl consulting, web development, and
  Technical DirectorUNIX/Linux systems architecture and automation. Mail
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

 + Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +


Re: Do I need to kill HEAP variables in _stop ?

2005-06-17 Thread Matt S Trout
On Fri, Jun 17, 2005 at 09:30:58PM +0400, Laura wrote:
 Do I need to kill HEAP variables in _stop ?
 
 for example
 
 sub _stop {
 
 undef $_[HEAP]-{VARIABLE};
 }
 
 or POE doing it automatically ?

When the session is finished, it's garbage-collected. So of course POE will,
unless you've got a reference do that variable somewhere else.

 thx

That is *not* english. Unless you're 15, in America, and borrowing your mum's
AOL account. Try thanks.

-- 
 Matt S Trout   Website: http://www.shadowcatsystems.co.uk
  Technical DirectorE-mail:  mst (at) shadowcatsystems.co.uk
Shadowcat Systems Ltd.


Re: How to make merged HASH for 2 packages ?

2005-06-09 Thread Matt S Trout
On Thu, Jun 09, 2005 at 10:38:03AM +0400, Laura wrote:
 hi, Philip, thank you for response.
 
 It must be a global hash, in TWO should be the same as ONE

So just do

HEAP = { HASH = $hashref }

on both startups.

It's a *reference*. Two references to the same variable still point to the
same variable.

-- 
 Matt S Trout   Website: http://www.shadowcatsystems.co.uk
  Technical DirectorE-mail:  mst (at) shadowcatsystems.co.uk
Shadowcat Systems Ltd.


Re: How to modify HEAP variables in subs...

2005-05-17 Thread Matt S Trout
On Tue, May 17, 2005 at 06:19:40PM +0400, Laura wrote:
 I can pass it along as an argument, but then event will 
 $_[KERNEL]-post(LADBI where i can`t pass that ARG...

LaDBI's events all take a UserData argument for just this purpose.

Have another look at the LaDBI docs :) -

 sub success_event_handler {
 ...
 my ($handle_id, $datatype, $data, $userdata) = @_[ARG0..ARG3];
 ...
  }

$userdata is whatever you passed as UserData = to the original LaDBI post.

That do the trick?

-- 
 Matt S Trout   Website: http://www.shadowcatsystems.co.uk
  Technical DirectorE-mail:  mst (at) shadowcatsystems.co.uk
Shadowcat Systems Ltd.


Re: How to modify HEAP variables in subs...

2005-05-16 Thread Matt S Trout
On Mon, May 16, 2005 at 03:06:51PM +0400, Laura wrote:
 Hi, please sorry, i`m newbie in POE and have a lot of 
 problems...
 
 Why doesn`t variables of HEAP changed?
 There is a little chunk of program(2 subs):
 
 sub one {
 
 $_[HEAP]-{VARIABLE}=0;
 for(1..4)
 {
 $_[KERNEL]-yield(two);
 }
 print VARIABLE: ,$_[HEAP]-{VARIABLE};
 
 }
 
 sub two {
 $_[HEAP]-{VARIABLE}++;
 }
 
 It will print VARIABLE: 0, but why? I`ve updated it in 
 'two', it must be 1(cause of ++).

Er, no. yield means put this event in the queue to be run, so your
two events aren't going to get called until after the one event
exits.

Replace the print with

$_[KERNEL]-yield(three);

and add

sub three {
  print VARIABLE: ,$_[HEAP]-{VARIABLE};
}

and I think you'll see the result you expect.

-- 
 Matt S Trout   Website: http://www.shadowcatsystems.co.uk
  Technical DirectorE-mail:  mst (at) shadowcatsystems.co.uk
Shadowcat Systems Ltd.


Re: LaDBI multiple connections problem Re: SimpleDBI - the same.

2005-05-05 Thread Matt S Trout
On Thu, May 05, 2005 at 06:39:23PM +0400, Alex wrote:
 yes,
 j - 2 iterations
 i - 150 iterations
 150*2= 300 :)
 
 double loop is just for 'sleep 1'
 
 Maximum there must be not more than 197 connections, i 
 don`t know why didn`t poe kill connection after DBI 
 operation, after _stop function connection is still alive. 
 Why? I don`t know :(
 
 I tried ladbi, simpledbi modules - the same errors :( Can 
 anyone help me ?

Have you considered the possibility that you're only *asking* the connection
to shut down in your _stop and it hasn't actually finished shutting down by
the time you spawn another connection?

-- 
Matt S TroutBrag sheet:http://trout.me.uk/services.html
LAMP, InfrastructureContact:   [EMAIL PROTECTED]
   and Automation
 specialist   Do it once. Do it right.


Re: Sanity Check

2005-04-30 Thread Matt S Trout
On Sat, Apr 30, 2005 at 10:19:04AM -0500, Wiggins d'Anconia wrote:
 I hate to say it but with all your various systems, protocols, etc. I 
 would start from scratch with an XML based config system. I don't throw 
 out XML lightly as I think it is overkill for a lot of things, but with 
 all the different setups you are talking about it can be very effective. 
  XML::Simple should do nicely.

At least a couple of people are using my Class::XML to automatically load
a tree of config objects from an XML file in a relatively clean format. I
find it much less of a pain in the neck, anyway :)

-- 
Matt S TroutBrag sheet:http://trout.me.uk/services.html
LAMP, InfrastructureContact:   [EMAIL PROTECTED]
   and Automation
 specialist   Do it once. Do it right.


Re: Where would I find the difference between post and yield?

2005-03-27 Thread Matt S Trout
On Sun, Mar 27, 2005 at 12:38:26PM -0600, Jay Strauss wrote:
 Hi,
 
 I used POE a couple of years ago.  Now I need to use it again, but can't 
 remember the stuff.
 
 Where in the docs would I find the definitions of -post -yield, what 
 arguments they take...

perldoc POE::Kernel

-- 
Matt S TroutBrag sheet:http://trout.me.uk/services.html
LAMP, InfrastructureContact:   [EMAIL PROTECTED]
   and Automation
 specialist   Do it once. Do it right.


Re: anyone using any of the HTTP server components in a heavy use environment?

2005-03-26 Thread Matt S Trout
On Thu, Mar 24, 2005 at 04:30:54PM -0800, David Davis wrote:
 I can give you what I have written... Apache::Backend::POE
 
 It hasn't been heavily tested or given a proper build and docs..but I
 can help you get started using it.
 
 It caches connections ala Apache::DBI too.
 
 Interested?

I'd be fascinated to see this; I've been pondering something along the
same lines, although I was looking at welding it into Maypole or similar.

Any chance you could either stick a copy to play with up to download
somewhere? (or mail it off-list if necessary, but I think there're a few
people wanting copies now :)

-- 
Matt S TroutBrag sheet:http://trout.me.uk/services.html
LAMP, InfrastructureContact:   [EMAIL PROTECTED]
   and Automation
 specialist   Do it once. Do it right.


Re: POE::Component::Client::Ident doesn?t tolerant identd answers with just \n as line seperator

2004-11-10 Thread Matt S Trout
On Tue, Nov 09, 2004 at 05:26:29PM -0500, sungo wrote:
 On (11/09 22:13), Markus M?ller wrote:
 
  Strictly seen, you?re right. The RFC needs \r\n. But you shouldn?t 
  ignore that this RFC is very old. 
 
 the tcp spec is old and we still follow it. if the rfc says \r\n, that's
 what you should send and what you should expect. 

*dons asbestos suit*

Not really. Be strict in what you emit, liberal in what you accept should
apply. Also, the \n vs. \r\n is one of the most common bugs in network protocol
implementations - hence the fact that you'll rarely see a qmail install that
doesn't use fixcrio in front of qmail-smtpd.

It's a good idea to have a strict mode available, but the default should always
be to fudge round the error *when it can be done unambiguously* - if they send
'\n' every time you'd expect '\r\n', it's pretty unambiguous that that's what's
going on and you should compensate accordingly. The above-quoted rule is a
fundamental design philosophy of both UNIX and the internet, and results in
software that's useful first and ideologically perfect second.

Of course I always really like ideological perfection too, but when I'm in
that frame of mind I tend to be writing Scheme :)

-- 
Bring me my etherkiller; Oh clouds unfold! / Bring me the magic smoke of desire
I shall not cease from mental fight / Nor shall my LART rest in my hand
Till we have buried the bodies / Of all the lusers in all this land
  -- rpg, ASR[ My homepage is http://www.trout.me.uk/ ]


Re: POE + database access

2004-11-08 Thread Matt S Trout
On Mon, Nov 08, 2004 at 03:45:27PM -0500, Oliver Klozoff wrote:
  From: David Davis [mailto:[EMAIL PROTECTED] 
  Sent: Monday, November 08, 2004 2:47 PM
  To: Oliver Klozoff
  Subject: Re: POE + database access
  
  We would have no idea what your problem is without showing us 
  any code.
  
  My reflex reason would be that you are using MSSQL :)
  
 
 That doesn't make much sense, as MSSQL is running on the database machine,
 while the program runs on the little Linux box under my desk ;)

I think the problem's in FreeTDS. I've seen similar behaviour in non-POE apps
using it. I'd suggest you implement some sort of health-check that restarts
the program if it locks. Also consider using one of the DBI PoCos to put the
DBI connection in a separate process that can be monitored from the main POE
run loop.

-- 
Bring me my etherkiller; Oh clouds unfold! / Bring me the magic smoke of desire
I shall not cease from mental fight / Nor shall my LART rest in my hand
Till we have buried the bodies / Of all the lusers in all this land
  -- rpg, ASR[ My homepage is http://www.trout.me.uk/ ]


Re: POE + database access

2004-11-08 Thread Matt S Trout
On Mon, Nov 08, 2004 at 08:10:52PM -0500, Oliver Klozoff wrote:
 Matt S Trout wrote:
 
 I think the problem's in FreeTDS. I've seen similar behaviour in non-POE 
 apps
 using it. I'd suggest you implement some sort of health-check that restarts
 the program if it locks. Also consider using one of the DBI PoCos to put 
 the
 DBI connection in a separate process that can be monitored from the main 
 POE
 run loop.
 
 
 I was starting to wonder if that was the problem, *sigh*.
 
 Would you be so kind as to offer a suggestion on how to implement such a 
 'health-check', or an example of using these DBI PoCos (or both)?

Have a look at

http://search.cpan.org/~segan/POE-Component-LaDBI-1.2.1/lib/POE/Component/LaDBI.pm

and then build something that sets a timer in the kernel, then if you don't get
a response back from PoCo::LaDBI in that time grabs $_[HEAP]-{wheel}-PID and
SIGKILLs it, starts a new LaDBI session and proceeds accordingly.

 Incidentally, if FreeTDS is truly the problem, that's good news -- for this 
 new project, I would use PostgreSQL, for which the client libraries may be 
 less... glitchy.

Write a program that does the same queries but doesn't actually do anything
with them, then run it and see if it hangs :)

Alternatively, compile with debug flags and throw gdb at it when it hangs,
see which bit of code it's in.

Also, try a CVS snapshot of FreeTDS - if you're lucky they're often
significantly better than the previous release.

-- 
Bring me my etherkiller; Oh clouds unfold! / Bring me the magic smoke of desire
I shall not cease from mental fight / Nor shall my LART rest in my hand
Till we have buried the bodies / Of all the lusers in all this land
  -- rpg, ASR[ My homepage is http://www.trout.me.uk/ ]


Re: trouble updating POE::Component::Client::HTTP

2004-09-02 Thread Matt S Trout
On Thu, Sep 02, 2004 at 09:44:32PM +0200, Bruno Boettcher wrote:
 Hello!
 
 made an update (and had also the very bad idea of making a forced update
 :( ) of POE and consorts...
 
 problem makes POE::Component::Client::HTTP 
 building etc runs fine, but the tests fail:
 
 Running make test
 PERL_DL_NONLAZY=1 /usr/bin/perl -MExtUtils::Command::MM -e test_harness(0, 
 'blib/lib', 'blib/arch') t/01_request.t
 t/01_requestFAILED tests 1-4, 7-8, 10
 Failed 7/10 tests, 30.00% okay
 Failed TestStat Wstat Total Fail  Failed  List of Failed
 ---
 t/01_request.t   107  70.00%  1-4 7-8 10
 Failed 1/1 test scripts, 0.00% okay. 7/10 subtests failed, 30.00% okay.
 make: *** [test_dynamic] Error 255
   /usr/bin/make test -- NOT OK
 
 uhm the message isn't very explicit about what goes wrong and why... but
 i know for sure that on most sites my scripts now return a 'server error
 500' instead oof the requested webpage... :(
 
 any possible hint?

Try running

perl t/01_request.t

by hand and having a look at the output.

-- 
Bring me my etherkiller; Oh clouds unfold! / Bring me the magic smoke of desire
I shall not cease from mental fight / Nor shall my LART rest in my hand
Till we have buried the bodies / Of all the lusers in all this land
  -- rpg, ASR[ My homepage is http://www.trout.me.uk/ ]