Americo-

I see you state that it is xp HOME. you should know that HOME has a LOT of 
the networking features permanently removed. While I don't know as much as 
Jan about perl, and his response may solve your problem, I do know that 
HOME is NOT meant to run as a server while PRO IS meant to have that 
capability. This could be compacting issues you have. if you truly want to 
make this box you're talking of a server, i suggest upgrading it to pro.

-Josh

> ------------------------------
> 
> Message: 2
> Date: Wed, 07 Dec 2005 14:27:31 +0000
> From: "Américo Albuquerque" <[EMAIL PROTECTED]>
> Subject: Problems with fork
> To: [email protected]
> Message-ID: <[EMAIL PROTECTED]>
> 
> 
> 
> 
> 
> Hello
> 
> I have a server application running on a WinXP Home Edition withSP2. It 
> accepts connections, fork to create a child that would deal with the 
> connection so the server would be ready to accept new connections. 
> 
> The server acts as a fork for POP protocol. it accept connection from a 
> client, check it's database for the supplied address and connects to the 

> correct POP3 server.
> 
> The problem is that the server only work for around 20 connections, 
after 
> that I get the "Can't fork: Resource temporarily unavailable" error. The 

> function that does the fork has a exit so it exits from the child but it 

> seams that it doesn't clean the resources used. Is there a way to make 
it 
> work in windows?
> 
> The $client object does the connection to the client but it doesn't do 
any 
> fork.
> 
> This is the function that does the fork:
> sub spawn {
>   my $self = shift;
>   my $sock = shift;
>   die "Need a Connection|" unless $sock;
>   unless(defined($self->{client})) {
>     $self->log("Don't have a client to run!");
>     print $sock "-ERR Don't have a client to run!$self->{EOL}";
>     return;
>   }
>   $SIG{CHLD} = 'IGNORE';
>   my $kidpid = fork();
>   unless(defined($kidpid)) {
>     $self->log("-ERR Can't fork: $!");
>     print $sock "-ERR Can't fork: $!$self->{EOL}";
>     return;
>   }
>   unless($kidpid) {
>     my $client = $self->{client}->clone();
>     my @ctime = $self->ctime();
>     $self->log("Spawn started at $ctime[6], 
$ctime[3]/$ctime[4]/$ctime[5] 
> $ctime[2]:$ctime[1]:$ctime[0]");
>     print $sock $Email::Message::CONNECT;
>     $self->login($sock, $client);
>     if($sock->connected) {
>       $self->log("Spawn connected.");
>       $client->Run($sock, $sock);
>     }
>     $self->log("Spwan died!");
>     exit(0);
>   }
> }
> 
> Thanks in advance,
> Americo
> 
> 
> 
> 
> 
> 
> ------------------------------
> 
> Message: 6
> Date: Wed, 7 Dec 2005 09:31:00 -0800
> From: "Jan Dubois" <[EMAIL PROTECTED]>
> Subject: RE: Problems with fork
> To: " 'Am?rico Albuquerque' "   <[EMAIL PROTECTED]>,
>    <[email protected]>
> Message-ID: <[EMAIL PROTECTED]>
> Content-Type: text/plain;   charset="iso-8859-1"
> 
> On Wed, 07 Dec 2005, Américo Albuquerque wrote:
> > The problem is that the server only work for around 20 connections, 
after
> > that I get the "Can't fork: Resource temporarily unavailable" error. 
The
> > function that does the fork has a exit so it exits from the child but 
it
> > seams that it doesn't clean the resources used. Is there a way to make 
it
> > work in windows?
> 
> You need to call waitpid() on all child processes to completely clean up
> their resources.  There is a limit of about 63 simultaneous forked 
threads
> in Perl on Windows, so I don't understand why you are only able to start 
20.
> 
> I haven't tried this, but if you don't want to track all your child 
processes
> by pid then you might get away by inserting this in front of your call 
to
> fork():
> 
>     1 while waitpid(-1,1) > 0;
> 
> It should reclaim outstanding resources of all children that have 
already
> terminated.  Your total number of simultaneous threads will still be 
limited
> to some number below 64 though.
> 
> Cheers,
> -Jan


_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to