postscript printer handshake problem

2000-04-08 Thread Zdenek Radouch


Problem:
I don't know how to configure the spooler to properly handshake
with a postscript printer (via standard parallel port).

Background:
I am trying to improve printer connectivity in my wife's graphic design
office.  The basic idea I had was to take the direct-attached postscript
printers that currently have direct connections to a Mac or PC, and
hang them off one of the freebsd machines I have, thus effectively
converting the printers to network printers.  I did that, and very quickly
found out that it does not quite work.

Details and my theory:
It is not exactly clear to me what's happening since the behavior is complex
and the errors are not simply obvious.  Additionally, the Windows and Mac
postscript drivers seems to have their own issues.

some of the problems I see are:
[Note that most of the files do get printed OK]

1) some files leave the printer in a busy state (this does not
happen with a short postscript test code.
This suggests missing Ctrl-D handshake from the spooler.
2) appending Ctrl-D to the files that leave the printer busy
causes an extra page to be ejected/printed.
Can't explain this.
3) Some jobs result in a extra page printed with the text "%%EOF"
on it.  I can't understand how the interpreter can let this
(DCS comment) through.
4) Some jobs do not get interpreted - the printer spews the postscript
source code - very annoying since a 20MB postscript source for
a two-page ad with graphics can make the printer waste an
entire box of paper.  This may be related to 3) above - the printer
clearly has a mode to pass ASCII through and print it without any
 interpretation - the question is how does this happen to a proper
 postscript source file.

It looks like there are at least two problems:

1) the freebsd spooler does not handshake properly with the printer
  I have been quite ignorant of the lpr subsystem, so I have
no idea how it is supposed to work, but based on my understanding
of postscript (feel free to correct me), I'd expect the following:
The spooler should examine the first couple bytes of the job file and look
for the DSC pattern (%!) and use that to decide whether or not the printer
is a postscript printer.  For a non postscript printer it can simply dump
the job file in the printer.  When talking to a postscript printer (really a
postscript interpreter), the spooler has to send Ctrl-D to indicate the end
of the job - the interpreter uses that to reset its current environment upon
completion of the current job, then sends Ctrl-D back to the spooler to
indicate that the next job can be started.  Without the Ctrl-D the printer
will assume that more pages are coming and either time out,
or possibly fail the subsequent postscript processing because code
from the previous job may still sit on the interpreters stack.

2) The windows driver clearly violates the DSC by inserting Ctrl-D at
the end of the postscript file (But given the other problems I can
see why they'd do that).


I'd really appreciate if someone who is familiar with the bsd spooler could
comment on this.  I am interested in how the spooler code currently works
when it comes to handshaking with postscript printers.

Of course, any other pointers are welcome; if this is known not to work,
let me know, too.

(BTW, the machine with the spooler runs freebsd 3.4 and the printer
sits on /dev/lpt0.  Also, the Mac and Windows boxes can print without
any problems when they are attached directly and  using their native
spoolers.)


Please respond to me directly at [EMAIL PROTECTED], 
I don't read this mailing list.  Thanks.

-Zdenek




To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: desire for ftp.internat.freebsd.org mirror

2000-04-08 Thread Mark Murray

  Mark Murray would know :-)
  
  I think there's a lot of stale cruft on ftp.internat.freebsd.org which
  doesn't need to be mirrored - Mark could probably tell us all which bits
  are suitable for mirroring (this should be documented somewhere for
  posterity)

Mostly packages and distfiles.

 covering_in_asbestos
 mirroring of all that stuff should be migrated to rsync(1), since this
 implicitly defines (in terms of standard archive'/distribution handling)
 a structured "package" like layout, so we would have several collections
 (freebsd-ftp/ freebsd-www/ freebsd-crypto-US/ freebsd-crypto-nonUS/ and
 so on...)
 thus, it would be easier to set up a mirror, the paths would be more
 standard, the updates would be better in sync (since rsync really does a
 good job in not just only checking if a file has a new datestamp) and
 the world would be a bit better ;-)
 /covering_in_asbestos

I could do this. What arre the setup concerns?

M
--
Mark Murray
Join the anti-SPAM movement: http://www.cauce.org


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



How to make sure that I compile MD5 based system

2000-04-08 Thread Alexey N. Dokuchaev

Hello!

I am using FreeBSD 4.0.  The thing is, that I want DES sources and
libraries hanging around (just in case), but the whole system be MD5 based
(including /sbin/init, other utils, and correct links in /lib).  I looked
at /etc/defaults/make.conf, but didn't and references of this kind, except
USA_RESIDENT.

So, when making world and stuff, how do I explicitly say to make MD5
system, having *all* the sources, both DES and MD5.

Thank you.


Cheers,

  /* Alexey N. Dokuchaev, more commonly   |*/
  /* known as DAN Fe  | mailto:[EMAIL PROTECTED]   */
  /*  | ICQ UIN: 38934845  */
  /* Novosibirsk State University | http://inet.ssc.nsu.ru/~danfe/ */
  /* Scientific Study Center Computer Lab |*/



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: How to make sure that I compile MD5 based system

2000-04-08 Thread Chris D. Faulhaber

On Sat, 8 Apr 2000, Alexey N. Dokuchaev wrote:

 Hello!
 
 I am using FreeBSD 4.0.  The thing is, that I want DES sources and
 libraries hanging around (just in case), but the whole system be MD5 based
 (including /sbin/init, other utils, and correct links in /lib).  I looked
 at /etc/defaults/make.conf, but didn't and references of this kind, except
 USA_RESIDENT.
 
 So, when making world and stuff, how do I explicitly say to make MD5
 system, having *all* the sources, both DES and MD5.
 

Using:

#NODESCRYPTLINKS=true   # do not replace libcrypt - libscrypt links

will ensure your libcrypt is not linked to the des-based libcrypt
(libdescrypt).

-
Chris D. Faulhaber - [EMAIL PROTECTED] - [EMAIL PROTECTED]

FreeBSD: The Power To Serve   -   http://www.FreeBSD.org



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: How to make sure that I compile MD5 based system

2000-04-08 Thread Alexey N. Dokuchaev

On Sat, 8 Apr 2000, Chris D. Faulhaber wrote:

 On Sat, 8 Apr 2000, Alexey N. Dokuchaev wrote:
 
  Hello!
  
  I am using FreeBSD 4.0.  The thing is, that I want DES sources and
  libraries hanging around (just in case), but the whole system be MD5 based
  (including /sbin/init, other utils, and correct links in /lib).  I looked
  at /etc/defaults/make.conf, but didn't and references of this kind, except
  USA_RESIDENT.
  
  So, when making world and stuff, how do I explicitly say to make MD5
  system, having *all* the sources, both DES and MD5.
  
 
 Using:
 
 #NODESCRYPTLINKS=true   # do not replace libcrypt - libscrypt links
 
 will ensure your libcrypt is not linked to the des-based libcrypt
 (libdescrypt).
 

But, AFAIUC, this deals only with libraries.  And how about binary
executables in /bin, /sbin (e.g., init)?


Cheers,

  /* Alexey N. Dokuchaev, more commonly   |*/
  /* known as DAN Fe  | mailto:[EMAIL PROTECTED]   */
  /*  | ICQ UIN: 38934845  */
  /* Novosibirsk State University | http://inet.ssc.nsu.ru/~danfe/ */
  /* Scientific Study Center Computer Lab |*/

[Team Assembler] [Team BSD] [Team DooM] [Team Quake]

-BEGIN GEEK CODE BLOCK-
Version: 3.12
GCS d-@ s+: a--- C++(+++) UBL$ P++$ L+
E-- W++ N++ o? K? w-- O- M V- PS PE Y+ PGP+
t+ 5+ X+ R- !tv b++ DI+ D+++ G++ e h !r !y+
--END GEEK CODE BLOCK--

Microsoft:  Where do you want to go today?
Linux:  Where do you want to go tomorrow?
FreeBSD:Are you guys coming or what?

Microsoft:  What are we going to rip off today and claim as our own?

Microsoft:  Where do you want to be taken today?



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



RE: make release + X

2000-04-08 Thread Brian Fundakowski Feldman

On Tue, 1 Feb 2000, Daniel O'Connor wrote:

 
 On 31-Jan-00 R.I.Pienaar wrote:
   how do i incorporate the XFree stuff into a freebsd release so that
   it is in
   acceptable format for sysinstall?
 
 Download the binary packages from XFree86.org..
 
 Someone was working on making the port produce tarballs that look like
 the XFree86 ones but I don't know how far that got.

Sorry for just seeing this message... it was I who was doing this, and I
completed it some time before 4.0-RELEASE.  If someone's interested, I'll
give it a check and post it.

 ---
 Daniel O'Connor software and network engineer
 for Genesis Software - http://www.gsoft.com.au
 "The nice thing about standards is that there
 are so many of them to choose from."
   -- Andrew Tanenbaum

--
 Brian Fundakowski Feldman   \  FreeBSD: The Power to Serve!  /
 [EMAIL PROTECTED]`--'



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: How to make sure that I compile MD5 based system

2000-04-08 Thread Chris D. Faulhaber

On Sat, 8 Apr 2000, Alexey N. Dokuchaev wrote:

 On Sat, 8 Apr 2000, Chris D. Faulhaber wrote:
 
  On Sat, 8 Apr 2000, Alexey N. Dokuchaev wrote:
  
   Hello!
   
   I am using FreeBSD 4.0.  The thing is, that I want DES sources and
   libraries hanging around (just in case), but the whole system be MD5 based
   (including /sbin/init, other utils, and correct links in /lib).  I looked
   at /etc/defaults/make.conf, but didn't and references of this kind, except
   USA_RESIDENT.
   
   So, when making world and stuff, how do I explicitly say to make MD5
   system, having *all* the sources, both DES and MD5.
   
  
  Using:
  
  #NODESCRYPTLINKS=true   # do not replace libcrypt - libscrypt links
  
  will ensure your libcrypt is not linked to the des-based libcrypt
  (libdescrypt).
  
 
 But, AFAIUC, this deals only with libraries.  And how about binary
 executables in /bin, /sbin (e.g., init)?
 

If a program links with libcrypt and libcrypt is linked to libscrypt (MD5
version) instead of libdescrypt (DES version), then that program will use
MD5.

-
Chris D. Faulhaber - [EMAIL PROTECTED] - [EMAIL PROTECTED]

FreeBSD: The Power To Serve   -   http://www.FreeBSD.org



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: How to make sure that I compile MD5 based system

2000-04-08 Thread Alexey N. Dokuchaev

On Sat, 8 Apr 2000, Chris D. Faulhaber wrote:

 If a program links with libcrypt and libcrypt is linked to libscrypt (MD5
 version) instead of libdescrypt (DES version), then that program will use
 MD5.
 

Got it.  Thanks.


Cheers,

  /* Alexey N. Dokuchaev, more commonly   |*/
  /* known as DAN Fe  | mailto:[EMAIL PROTECTED]   */
  /*  | ICQ UIN: 38934845  */
  /* Novosibirsk State University | http://inet.ssc.nsu.ru/~danfe/ */
  /* Scientific Study Center Computer Lab |*/



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



What are the best gcc optimization options for Pentium 200 MMX

2000-04-08 Thread Alexey N. Dokuchaev

Hi!

AFAIK, Linux Mandrake has it's kernel and userland highly optimized for
Pentium architecture.  However, they have additional gcc optimization 
flags turned on by default, including -O3 and -mfast_math.

I'm trying to achive maximum performance of my FreeBSD 4.0-RELEASE box,
and going to recompile kernel and world using -Os -pipe options.  Is there
any additional flags I might consider turning on (like -mfast_math) to
make both kernel and world work at the top performance I can achieve?

Of course, I could just man gcc and turn every option I find useful, but I
don't have _that_ much experience with gcc as (I am sure) certain people
on this maillist have.  So not to run into any problems in the future
caused by my 'overoptimized' system, I would like to get deep and full
answer here.  Thank you in advance.

System is: genuine intel Pentium 200 MMX proc, 64M memory, FreeBSD 4.0-R

P.S.  Please cc me directly, since I am not the member of this list.


Cheers,

  /* Alexey N. Dokuchaev, more commonly   |*/
  /* known as DAN Fe  | mailto:[EMAIL PROTECTED]   */
  /*  | ICQ UIN: 38934845  */
  /* Novosibirsk State University | http://inet.ssc.nsu.ru/~danfe/ */
  /* Scientific Study Center Computer Lab |*/

[Team Assembler] [Team BSD] [Team DooM] [Team Quake]

-BEGIN GEEK CODE BLOCK-
Version: 3.12
GCS d-@ s+: a--- C++(+++) UBL$ P++$ L+
E-- W++ N++ o? K? w-- O- M V- PS PE Y+ PGP+
t+ 5+ X+ R- !tv b++ DI+ D+++ G++ e h !r !y+
--END GEEK CODE BLOCK--

Microsoft:  Where do you want to go today?
Linux:  Where do you want to go tomorrow?
FreeBSD:Are you guys coming or what?

Microsoft:  What are we going to rip off today and claim as our own?

Microsoft:  Where do you want to be taken today?



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



FreeBSD 3.3 fork/Exec bug?

2000-04-08 Thread Sean Peck


I am having a bizarre problem with a system on FreeBSD.

The system consists of a server who forks its clients.
When the clients are forked, they try to connect to the server and get
information.  Unfortunately when they fork off (fork/execlp), they say
they connected to
server and recieved nothing, yet the server does not register the
connection or request for info.  If I run the client independently (not
via fork/execlp)  everything works just fine.

This code is deployed and operational on BSDi without a problem, so I
assume that this is OS related, does anyone know anything about, or can
help me with this?

Sean


Sean Peck
News Index -- The original News Only Search Engine.
http://www.newsindex.com/



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: What are the best gcc optimization options for Pentium 200 MMX

2000-04-08 Thread Pedro F. Giffuni

FWIW, I understand that they carry pgcc (http://www.goof.com) which may
be very risky under Linux. Linus doesn't even recommend the latest gcc
because he likes to keep his kernel dependent on the old (non-standard)
features.

Look in the archives, I recall someone benchmarked the new gcc on this
list. the FAQ on goof.com is also interesting if you want to try out
pgcc on FreeBSD.

cheers,

 Pedro.

"Alexey N. Dokuchaev" wrote:
 
 Hi!
 
 AFAIK, Linux Mandrake has it's kernel and userland highly optimized for
 Pentium architecture.  However, they have additional gcc optimization
 flags turned on by default, including -O3 and -mfast_math.
 
 I'm trying to achive maximum performance of my FreeBSD 4.0-RELEASE box,
 and going to recompile kernel and world using -Os -pipe options.  Is there
 any additional flags I might consider turning on (like -mfast_math) to
 make both kernel and world work at the top performance I can achieve?
 
 Of course, I could just man gcc and turn every option I find useful, but I
 don't have _that_ much experience with gcc as (I am sure) certain people
 on this maillist have.  So not to run into any problems in the future
 caused by my 'overoptimized' system, I would like to get deep and full
 answer here.  Thank you in advance.
 
 System is: genuine intel Pentium 200 MMX proc, 64M memory, FreeBSD 4.0-R
 
 P.S.  Please cc me directly, since I am not the member of this list.
 
 Cheers,
 
   /* Alexey N. Dokuchaev, more commonly   |*/
   /* known as DAN Fe  | mailto:[EMAIL PROTECTED]   */
   /*  | ICQ UIN: 38934845  */
   /* Novosibirsk State University | http://inet.ssc.nsu.ru/~danfe/ */
   /* Scientific Study Center Computer Lab |*/
 
 [Team Assembler] [Team BSD] [Team DooM] [Team Quake]
 
 -BEGIN GEEK CODE BLOCK-
 Version: 3.12
 GCS d-@ s+: a--- C++(+++) UBL$ P++$ L+
 E-- W++ N++ o? K? w-- O- M V- PS PE Y+ PGP+
 t+ 5+ X+ R- !tv b++ DI+ D+++ G++ e h !r !y+
 --END GEEK CODE BLOCK--
 
 Microsoft:  Where do you want to go today?
 Linux:  Where do you want to go tomorrow?
 FreeBSD:Are you guys coming or what?
 
 Microsoft:  What are we going to rip off today and claim as our own?
 
 Microsoft:  Where do you want to be taken today?
 
 To Unsubscribe: send mail to [EMAIL PROTECTED]
 with "unsubscribe freebsd-hackers" in the body of the message


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



RE: What are the best gcc optimization options for Pentium 200 M

2000-04-08 Thread Alexander N. Kabaev

I doubt Mandrake gets any significant performance boost from using gcc with
optimisation levels beyond -O. They just use this "super optimised" to
stand out from all other Linux crowd rather than for any practical purpose. It
has been reported several times that optimisation levels O2 ang higher are
buggy and known to generate wrong code on several occasions. This was true for
gcc 2.7.2.3 and it is still true for gcc 2.95.2. In other words, your attempt to
squeese last drop of performance from your system in this way is futile :). The
gain you will get is just not worth associated risks.

On 08-Apr-00 Alexey N. Dokuchaev wrote:
 Hi!
 
 AFAIK, Linux Mandrake has it's kernel and userland highly optimized for
 Pentium architecture.  However, they have additional gcc optimization 
 flags turned on by default, including -O3 and -mfast_math.
 
 I'm trying to achive maximum performance of my FreeBSD 4.0-RELEASE box,
 and going to recompile kernel and world using -Os -pipe options.  Is there
 any additional flags I might consider turning on (like -mfast_math) to
 make both kernel and world work at the top performance I can achieve?
 
 Of course, I could just man gcc and turn every option I find useful, but I
 don't have _that_ much experience with gcc as (I am sure) certain people
 on this maillist have.  So not to run into any problems in the future
 caused by my 'overoptimized' system, I would like to get deep and full
 answer here.  Thank you in advance.
 
 System is: genuine intel Pentium 200 MMX proc, 64M memory, FreeBSD 4.0-R
 
 P.S.  Please cc me directly, since I am not the member of this list.
 
 
 Cheers,
 
   /* Alexey N. Dokuchaev, more commonly   |*/
   /* known as DAN Fe  | mailto:[EMAIL PROTECTED]   */
   /*  | ICQ UIN: 38934845  */
   /* Novosibirsk State University | http://inet.ssc.nsu.ru/~danfe/ */
   /* Scientific Study Center Computer Lab |*/
 
   [Team Assembler] [Team BSD] [Team DooM] [Team Quake]
 
 -BEGIN GEEK CODE BLOCK-
 Version: 3.12
 GCS d-@ s+: a--- C++(+++) UBL$ P++$ L+
 E-- W++ N++ o? K? w-- O- M V- PS PE Y+ PGP+
 t+ 5+ X+ R- !tv b++ DI+ D+++ G++ e h !r !y+
 --END GEEK CODE BLOCK--
 
 Microsoft:Where do you want to go today?
 Linux:Where do you want to go tomorrow?
 FreeBSD:  Are you guys coming or what?
 
 Microsoft:What are we going to rip off today and claim as our own?
 
 Microsoft:Where do you want to be taken today?
 
 
 
 To Unsubscribe: send mail to [EMAIL PROTECTED]
 with "unsubscribe freebsd-hackers" in the body of the message

--
E-Mail: Alexander N. Kabaev [EMAIL PROTECTED]
Date: 08-Apr-00
Time: 11:07:16
--


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: FreeBSD 3.3 fork/Exec bug?

2000-04-08 Thread Alfred Perlstein

* Sean Peck [EMAIL PROTECTED] [000408 07:58] wrote:
 
 I am having a bizarre problem with a system on FreeBSD.
 
 The system consists of a server who forks its clients.
 When the clients are forked, they try to connect to the server and get
 information.  Unfortunately when they fork off (fork/execlp), they say
 they connected to
 server and recieved nothing, yet the server does not register the
 connection or request for info.  If I run the client independently (not
 via fork/execlp)  everything works just fine.
 
 This code is deployed and operational on BSDi without a problem, so I
 assume that this is OS related, does anyone know anything about, or can
 help me with this?

Without some example code to demostrate the problem there's not much
we can do to address this.

-- 
-Alfred Perlstein - [[EMAIL PROTECTED]|[EMAIL PROTECTED]]
"I have the heart of a child; I keep it in a jar on my desk."


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: FreeBSD 3.3 fork/Exec bug?

2000-04-08 Thread Sean Peck

Alfred,

  Here is the code being used.

This is the Server Code, xxx are the IP of box, yyy is port this server is
listening too passed to the client

user_port = socket_config();
while (y1){
  if(!fork()){
  printf("Starting Client  %d\n",getpid());
  close(user_port);
  execlp("./client","client","XXX.XXX.XXX.XXX","",NULL);
  printf("Ending forked %d\n",xxx);
  exit(0);
}
y++;
}

=

This is the client main


 sleep(10);  //this is just to make sure that the server is ready to
// listen  added for tracing and testing of this bug
if(argc3){printf("Usage get host port\n");exit(0);}
strcpy(localhostname,argv[1]);
port1 = atoi(argv[2]);
 printf("Connectiong to %s port %d\n",localhostname,port1);
signal(SIGPIPE,SIG_IGN);

 result=10;

printf("GETTING PAGE FROM SERVER\n");
while((strcmp(buf,"NONE")!=0)(result!=TCP_CONNECT_NONE)(timeout!=10)){
 memset(buf,0,sizeof(buf));
 result=10;
 timeout=0;

 while((result !=1)(result!=TCP_CONNECT_NONE)(timeout!=10)){
  result = tcp_get_conn(localhostname,port1,10,sock1);
  if(result==TCP_CONNECT_TIMEOUT){timeout++;}
 }
 printf("result %d\n",result);  //This is coming back 1 in both the
// fork/execlp and in direct from shell
// running
 printf("ERRNO %d\n",errno);   // this is coming back 36 in both shell and
// fork/execlp

 if ((result!=TCP_CONNECT_NONE)(timeout!=10)){
 write(sock1,"GIMME\n",6); 
 bufp=buf;
 //Does not appeart to be blocking
while((size=read(sock1, bufp, (5000-(bufp-buf0){
  printf("size %d\n",size);
 bufp+=size;
   }
 }
close(sock1);
 printf("GOT INFO\n");
 if(timeout==10){strcpy(buf,"NONE");}
 printf("GOT BUF: %s\n",buf);   // In fork this comes back with Empty   
// string, but has valid data if 
// run seperately.  When forked, Server
// just stays in select state, never 
// gets any connections, but clients
// execute as if they have one.

=

Here is the tcp_get_connection() code

/*
 * given a HOST name and service PORT number, return connected TCP
 * socket to the requested service at the requested host.  It will
 * timeout after SECS (if  0 then hang).  Passes back socket in SOCKP
 * and returns error codes.
 */

/* tcp_get_conn return codes */
#define TCP_NO_ERROR1   /* no error */
#define TCP_NOT_FOUND   2   /* host not found */
#define TCP_SOCKET_FAILURE  3   /* socket create failure
*/
#define TCP_CONNECT_ERROR   4   /* socket connect error */
#define TCP_CONNECT_TIMEOUT 5   /* socket connect timeout
*/
#define TCP_CONNECT_NONE6   /* socket didn't connect
*/
#define TCP_TRANSFER_ERROR  7   /* read/write error */

EXPORT  int tcp_get_conn(const char * host, const int port,
 const int secs, int * sockp)
{
  struct sockaddr_insadr;
  struct hostent*hostp;
  struct timevaltimeout, *timeoutp;
  fd_setfds;
  char  **addrp, okay = 0;
  int   sock, ret;
#ifdef __osf__
  struct itimerval  timer;
#endif
  
  /* locate host */
  hostp = gethostbyname(host);
  if (hostp == NULL)
return TCP_NOT_FOUND;
  
  /* setup internet port */
  sadr.sin_family = (u_short)AF_INET;
  sadr.sin_port = htons(port);
  
  sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
  if (sock  0)
return TCP_SOCKET_FAILURE;
  
#ifndef __osf__
  /* make the fd non-blocking */
  (void)fcntl(sock, F_SETFL, fcntl(sock, F_GETFL, 0) | O_NONBLOCK);
#endif
  
  if (secs  0)
timeoutp = 0L;
  else
timeoutp = timeout;
  FD_ZERO(fds);
  
  /* try to connect to the remote server */
  for (addrp = hostp-h_addr_list; *addrp != NULL; addrp++) {
(void)memcpy((void *)sadr.sin_addr, *addrp, sizeof(sadr.sin_addr));

#ifdef __osf__
/* set the timer */
timer.it_interval = timeout;
setitimer(ITIMER_REAL, timer, NULL);
(void)signal(SIGALRM, catch_alarm);
alarm_caught = FALSE;
#endif

/* connect or start the connection */
ret = connect(sock, (void *)sadr, sizeof(sadr));

#ifdef __osf__
/* disable the timer */
timer.it_value.tv_sec = 0;
timer.it_value.tv_usec = 0;
setitimer(ITIMER_REAL, timer, NULL);
(void)signal(SIGALRM, SIG_IGN);
#endif

if (ret == 0) {
  okay = 1;
  break;
}

#ifdef __osf__
(void)close(sock);

if (alarm_caught)
  return TCP_CONNECT_TIMEOUT;
else
  return TCP_CONNECT_ERROR;
#endif

/* not waiting for connection? */

if (errno != EINPROGRESS  errno != EWOULDBLOCK) {
  /* connection refused? */


Re: FreeBSD 3.3 fork/Exec bug?

2000-04-08 Thread Alfred Perlstein

* Sean Peck [EMAIL PROTECTED] [000408 09:47] wrote:
 Alfred,
 
   Here is the code being used.

ew. :P  There seems to be some problems in your tcp connect library...

  while((result !=1)(result!=TCP_CONNECT_NONE)(timeout!=10)){
   result = tcp_get_conn(localhostname,port1,10,sock1);
   if(result==TCP_CONNECT_TIMEOUT){timeout++;}
  }
  printf("result %d\n",result);  //This is coming back 1 in both the
   // fork/execlp and in direct from shell
   // running
  printf("ERRNO %d\n",errno);   // this is coming back 36 in both shell and
   // fork/execlp

36 is EINPROGRESS, somehow your connect function isn't handling non-blocking
connects properly.

 Here is the tcp_get_connection() code
 
 /*
  * given a HOST name and service PORT number, return connected TCP
  * socket to the requested service at the requested host.  It will
  * timeout after SECS (if  0 then hang).  Passes back socket in SOCKP
  * and returns error codes.
  */
 
 /* tcp_get_conn return codes */
 #define TCP_NO_ERROR  1   /* no error */
 #define TCP_NOT_FOUND 2   /* host not found */
 #define TCP_SOCKET_FAILURE3   /* socket create failure
 */
 #define TCP_CONNECT_ERROR 4   /* socket connect error */
 #define TCP_CONNECT_TIMEOUT   5   /* socket connect timeout
 */
 #define TCP_CONNECT_NONE  6   /* socket didn't connect
 */
 #define TCP_TRANSFER_ERROR7   /* read/write error */
 
 EXPORTint tcp_get_conn(const char * host, const int port,
const int secs, int * sockp)
 {
   struct sockaddr_in  sadr;
   struct hostent  *hostp;
   struct timeval  timeout, *timeoutp;
   fd_set  fds;
   char**addrp, okay = 0;
   int sock, ret;
 #ifdef __osf__
   struct itimervaltimer;
 #endif
   
   /* locate host */
   hostp = gethostbyname(host);
   if (hostp == NULL)
 return TCP_NOT_FOUND;
   
   /* setup internet port */
   sadr.sin_family = (u_short)AF_INET;
   sadr.sin_port = htons(port);
   
   sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
   if (sock  0)
 return TCP_SOCKET_FAILURE;
   
 #ifndef __osf__
   /* make the fd non-blocking */
   (void)fcntl(sock, F_SETFL, fcntl(sock, F_GETFL, 0) | O_NONBLOCK);
 #endif
   
   if (secs  0)
 timeoutp = 0L;
   else
 timeoutp = timeout;
   FD_ZERO(fds);
   
   /* try to connect to the remote server */
   for (addrp = hostp-h_addr_list; *addrp != NULL; addrp++) {
 (void)memcpy((void *)sadr.sin_addr, *addrp, sizeof(sadr.sin_addr));
 
 #ifdef __osf__
 /* set the timer */
 timer.it_interval = timeout;
 setitimer(ITIMER_REAL, timer, NULL);
 (void)signal(SIGALRM, catch_alarm);
 alarm_caught = FALSE;
 #endif
 
 /* connect or start the connection */
 ret = connect(sock, (void *)sadr, sizeof(sadr));
 
 #ifdef __osf__
 /* disable the timer */
 timer.it_value.tv_sec = 0;
 timer.it_value.tv_usec = 0;
 setitimer(ITIMER_REAL, timer, NULL);
 (void)signal(SIGALRM, SIG_IGN);
 #endif
 
 if (ret == 0) {
   okay = 1;
   break;
 }
 
 #ifdef __osf__
 (void)close(sock);
 
 if (alarm_caught)
   return TCP_CONNECT_TIMEOUT;
 else
   return TCP_CONNECT_ERROR;
 #endif
 
 /* not waiting for connection? */
 
 if (errno != EINPROGRESS  errno != EWOULDBLOCK) {
   /* connection refused? */
 
   if (errno == ECONNREFUSED)
   continue;
 
   /* otherwise error */
   (void)close(sock);
   return TCP_CONNECT_ERROR;
 }
 
 for (;;) {

FD_ZERO here?

   FD_SET(sock, fds);
   if (secs = 0) {
   timeout.tv_sec = secs;
   timeout.tv_usec = 0;
   }
   
   ret = select(sock + 1, 0L, fds, 0L, timeoutp);

0L - NULL please :)

   if (ret  0  FD_ISSET(sock, fds)) {
   okay = 1;
   break;
   }
   if (ret == 0) {
   (void)close(sock);
   return TCP_CONNECT_TIMEOUT;
   }
   if (ret  0  errno != EINTR) {
   (void)close(sock);
   return TCP_CONNECT_ERROR;
   }
 }
 
 if (okay)
   break;
   }
   
   /* connection made? */
   if (okay) {
 #ifndef __osf__
 /* turn off non-blocking */
 (void)fcntl(sock, F_SETFL, fcntl(sock, F_GETFL, 0)  ~O_NONBLOCK);
 #endif
 *sockp = sock;
 return TCP_NO_ERROR;
   }
   
   (void)close(sock);
   return TCP_CONNECT_NONE;
 }
 

Pick up a copy of Unix Netork Programming vol I, see page 411, it
has a very good example on how to do non-blocking connects properly.

-- 
-Alfred Perlstein - [[EMAIL PROTECTED]|[EMAIL PROTECTED]]
"I have the heart of a child; I keep it in a jar on my desk."


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: desire for ftp.internat.freebsd.org mirror

2000-04-08 Thread Joshua Goodall


I can't get there. Latency  packetloss too high from my cable modem in
NL.

Amusingly the route goes through the US :)

- J

On Thu, 6 Apr 2000, David O'Brien wrote:

 On Thu, Apr 06, 2000 at 12:47:16PM -0700, Kris Kennaway wrote:
  I guess the thing to do is to make sure they have the same directory
  structure as internat though, so people can simply substitute e.g.
  ftp2.internat.freebsd.org for something which tries to fetch(1) from
  internat.
 
 Can someone that can actually get into ftp.internat.freebsd.org compare
 them?
  
 



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: FreeBSD 3.3 fork/Exec bug?

2000-04-08 Thread Matthew Dillon


: they connected to
: server and recieved nothing, yet the server does not register the
: connection or request for info.  If I run the client independently (not
: via fork/execlp)  everything works just fine.
: 
: This code is deployed and operational on BSDi without a problem, so I
: assume that this is OS related, does anyone know anything about, or can
: help me with this?
:
:Without some example code to demostrate the problem there's not much
:we can do to address this.
:

This kinda sounds like a case where the server process has its
listen descriptor and when it fork/exec's the child it is either
not setting the close-on-exec flag for the descriptor, or the
child is not closing the descriptor.  Since this is an exec,
I'll bet the problem is that the server is not setting the
close-on-exec flag for the descriptor.

-Matt
Matthew Dillon 
[EMAIL PROTECTED]


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: What are the best gcc optimization options for Pentium 200 MMX

2000-04-08 Thread Matthew Dillon

:On Sat, 8 Apr 2000, Alexey N. Dokuchaev wrote:
:
: AFAIK, Linux Mandrake has it's kernel and userland highly optimized for
: Pentium architecture.  However, they have additional gcc optimization 
: flags turned on by default, including -O3 and -mfast_math.
:
:Can you say "gimmick"? :-) gcc often produces demonstrably broken code for
:optimisation levels higher than -O.
:
:Probably the only useful and safe option apart from -O is the
:-march=pentium/pentiumpro/pentiumii/etc option for using
:processor-specific opcodes and instruction scheduling.
:Kris

I use -Os for everything.  I wouldn't bother with anything else.  Someone
ran a bunch of benchmarks with various gcc/egcs options a while back
and, frankly, the top half dozen combinations were so close to each
other performance-wise that it just didn't matter.  -Os was in that
group, but also produced significantly smaller binaries.

I wouldn't touch the -march stuff at all, nor would I use -O3 (which
tries to inline standard static functions verses -O2) - that's useless
on IA32 because call/returns are very fast (I had an argument with John
Dyson about call/return overhead verses an L1 cache miss and
we ran a bunch of timings.  I lost the argument :-) call/return won the
race handily).


-Matt
Matthew Dillon 
[EMAIL PROTECTED]


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: What are the best gcc optimization options for Pentium 200 MMX

2000-04-08 Thread Kenneth Wayne Culver

Why exactly whould you not touch the -march options? I have had no
problems using them, and my system (5.0-CURRENT) seems a little faster
with -march=i686. I could be wrong though as I havn't done any exact
tests... it just seems a bit more responsive..


=
| Kenneth Culver  | FreeBSD: The best OS around.|
| Unix Systems Administrator  | ICQ #: 24767726 |
| and student at The  | AIM: muythaibxr |
| The University of Maryland, | Website: (Under Construction)   |
| College Park.   | http://www.wam.umd.edu/~culverk/|
=

On Sat, 8 Apr 2000, Matthew Dillon wrote:

 :On Sat, 8 Apr 2000, Alexey N. Dokuchaev wrote:
 :
 : AFAIK, Linux Mandrake has it's kernel and userland highly optimized for
 : Pentium architecture.  However, they have additional gcc optimization 
 : flags turned on by default, including -O3 and -mfast_math.
 :
 :Can you say "gimmick"? :-) gcc often produces demonstrably broken code for
 :optimisation levels higher than -O.
 :
 :Probably the only useful and safe option apart from -O is the
 :-march=pentium/pentiumpro/pentiumii/etc option for using
 :processor-specific opcodes and instruction scheduling.
 :Kris
 
 I use -Os for everything.  I wouldn't bother with anything else.  Someone
 ran a bunch of benchmarks with various gcc/egcs options a while back
 and, frankly, the top half dozen combinations were so close to each
 other performance-wise that it just didn't matter.  -Os was in that
 group, but also produced significantly smaller binaries.
 
 I wouldn't touch the -march stuff at all, nor would I use -O3 (which
 tries to inline standard static functions verses -O2) - that's useless
 on IA32 because call/returns are very fast (I had an argument with John
 Dyson about call/return overhead verses an L1 cache miss and
 we ran a bunch of timings.  I lost the argument :-) call/return won the
 race handily).
 
 
   -Matt
   Matthew Dillon 
   [EMAIL PROTECTED]
 
 
 To Unsubscribe: send mail to [EMAIL PROTECTED]
 with "unsubscribe freebsd-hackers" in the body of the message
 



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: What are the best gcc optimization options for Pentium 200 MMX

2000-04-08 Thread Matthew Dillon


:
:Why exactly whould you not touch the -march options? I have had no
:problems using them, and my system (5.0-CURRENT) seems a little faster
:with -march=i686. I could be wrong though as I havn't done any exact
:tests... it just seems a bit more responsive..
:
:=
:| Kenneth Culver  | FreeBSD: The best OS around.|

A couple of reasons, but the two main ones are:

* They are still under development

* They won't do what you expect (for example, the pentium optimizations
  often produce faster code on a PIII then the i686 optimizations)

* They *have* been known to generate bad code, owing to being under
  constant development.

* And your binaries won't necessarily be portable between 
  manufacturers (AMD vs Intel), or performance may suffer.

-Matt



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: What are the best gcc optimization options for Pentium 200 MMX

2000-04-08 Thread David Malone

On Sat, Apr 08, 2000 at 09:25:16PM +0700, Alexey N. Dokuchaev wrote:

 I'm trying to achive maximum performance of my FreeBSD 4.0-RELEASE box,
 and going to recompile kernel and world using -Os -pipe options.  Is there
 any additional flags I might consider turning on (like -mfast_math) to
 make both kernel and world work at the top performance I can achieve?

I thought there was no floating point code in the kernel, and so
-mfast-math wouldn't make any difference. I presume Linux doesn't
have any FPU code in the kernel either, to save having to save/restore
the registers on syscalls?

David.


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: What are the best gcc optimization options for Pentium 200 MMX

2000-04-08 Thread Kenneth Wayne Culver

Thanks :-)


=
| Kenneth Culver  | FreeBSD: The best OS around.|
| Unix Systems Administrator  | ICQ #: 24767726 |
| and student at The  | AIM: muythaibxr |
| The University of Maryland, | Website: (Under Construction)   |
| College Park.   | http://www.wam.umd.edu/~culverk/|
=




To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message