Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: rshd running out of privileged ports



> -----Original Message-----
> From: Peter Bierman [mailto:email@hidden]
> Sent: Thursday, March 04, 2004 11:19 AM
> To: Mark Armstrong
> Cc: email@hidden
> Subject: Re: rshd running out of privileged ports
>
>
> At 6:39 PM -0800 3/3/04, Mark Armstrong wrote:
> >Hello all,
> >
> >We have a build environment based upon Microsoft VC++ which
> rsh's the build
> >commands to the Mac. If the compile-file rate is too high, we
> start getting
> >rshd errors. When rsh'ing rapidly, rshd on the Mac seems to be
> running out
> >of privileged ports to open stderr upon. The following script
> was created
> >to show and reproduce the errors. It has been run from various Unix
> >machines and a similar script has been run from a Window machine all with
> >the same errors occurring:
> >
> >#!/bin/sh
> >loop=0
> >while [ $loop -lt 1000 ]; do
> > echo $loop;
> > rsh mackie sleep 0;
> > loop=$(( $loop + 1 ));
> >done
> >
> >Each rsh only does a sleep. After 42 runs, the rshd errors with:
> >"can't get stderr port: Can't assign requested address"
> >
> >This goes on for a while and then clears itself up after ~50
> seconds. Then
> >the whole cycle starts over again.
> >
> >I have enabled rshd through "xinetd.d/shell". I have tried to
> set various
> >kernel parameters and nothing seems to affect the outcome. It
> seems to have
> >lingering sockets, or something similar. I have taken the
> Darwin source for
> >rshd.c and modified it to try to resolve this problem with no luck.
>
>
> Well, there's only 1024 reserved ports, and if rsh uses TCP, then
> they have to sit in CLOSE_WAIT for two minutes before being reused.
>
> I'm surprised you don't see this on other platforms.
>
> You said you modified rshd.c, what did you change?

Modified to be a little bit more explicit about the error and make sure that
it shut down and closed the open sockets. Tried other misc. things just to
get a better idea of what was happening.

>
> You probably need to set SO_REUSEADDR on the socket.
>
> http://www.unixguide.net/network/socketfaq/4.5.shtml
>
>
> socket(...);
>
> int p=1;
> setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char *)&p,sizeof(int));
>
> bind(...);
> listen(...);
>
> -pmb

I tried the SO_REUSEADDR and it did not change the behavior. I haven't
looked deeper into the rresvport call that rshd.c uses to get the stderr
socket. There is other behavior which I need to find. Since we don't
experience this problems with other O/S's, they must either be using less of
the reserved ports normally and we are just getting lucky or their
reserved/privileged sockets are not lingering for as long.

Do you have any other suggestions? Currently, we can get around this
problem by making sure that each compile job lasts at least a couple of
seconds. We are putting a sleep after each rsh gcc invocation. I don't
like doing this because we are only hoping that the timing is such that we
won't run out of sockets for rshd to use.

Thanks for the response,
Mark
_______________________________________________
darwin-userlevel mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-userlevel
Do not post admin requests to the list. They will be ignored.


References: 
 >Re: rshd running out of privileged ports (From: Peter Bierman <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.