Return to BSD News archive
Newsgroups: comp.os.386bsd.questions Path: sserve!newshost.anu.edu.au!munnari.oz.au!spool.mu.edu!agate!msuinfo!netnews.upenn.edu!dsinc!jabber!candle!root From: root@candle.uucp (Bruce Momjian) Subject: Re: [NetBSD 0.9] Pcomm a hog for you? References: <2g7o24$iir@explorer.clark.net> Organization: a consultant's basement Date: Mon, 3 Jan 1994 02:53:52 GMT X-Newsreader: TIN [version 1.2 PL2] Message-ID: <CJ19Dt.M06@candle.uucp> Lines: 261 Eric S. Hvozda (ack@clark.net) wrote: : It seems that Pcomm wants to suck the CPU alot more and gets silo : over flows more often than kermit. These observations were made while : running X, so the load is basically about the same, and the CPU is : actaully doing something other than sitting around. : So anyway, has anyone else noticed this? Yes, I have noticed this. Attached is a posting I made to the bsdi users (BSD/386) mailing list, and sent to pcomm's creator for inclusion in the next release. It details several problems with BSD support in pcomm release 2.0.2, and includes a patch to fix those problems. If you run ktrace on pcomm, you will see the select() does not sleep as it should. --------------------------------------------------------------------------- From maillist Sun Jun 13 23:16:59 1993 Subject: Porting pcomm 2.0.2 To: bsdi-users@bsdi.com (bsdi maillist (not as root)) Date: Sun, 13 Jun 1993 23:16:59 -40962758 (EDT) X-Mailer: ELM [version 2.4 PL20] Content-Type: text Content-Length: 5175 Status: OR Here is a patch to get pcomm 2.0.2 for to BSD/386. This patch does fix several things: adds local/nolocal calls to tty_ucb. Without it, it can't dial. added the FD_* calls to ipc_bsd to properly set file descriptor masks. Fixed initialization bug. Without these fixes, pcomm will not sleep in the select and eat tons of cpu. fixed loop of function calls in chg_dir.c Apply this context diff with 'patch', compile fix.c seperately to fix.o and add fix.o to the final link. I may not have done the best job with these patches. Let me know if you have problems. I will contact the author to try and get these fixes into the final release. Pcomm 2.0.2 was posted to comp.sources.unix/misc recently. Pcomm is a procomm clone, used to dial the modem. ---------------------------------------------------------------------- *** ipc_ucb.c.orig Sat Jun 12 21:00:53 1993 --- ipc_ucb.c Sat Jun 12 22:54:42 1993 *************** *** 12,18 **** #include "ipc.h" static char pty_name[12]; ! static int fdin_mask, num_fds; static struct timeval time_out = {1L, 0L}; static struct timeval *tp; --- 12,19 ---- #include "ipc.h" static char pty_name[12]; ! static int num_fds; ! static fd_set fdin_mask; static struct timeval time_out = {1L, 0L}; static struct timeval *tp; *************** *** 20,37 **** ipc_init(tty_fd, cmd_fd) int tty_fd, cmd_fd; { ! int fdout, fdin, fdex; ! fdout = 0; ! fdex = 0; ! fdin_mask = 1; /* the keyboard */ num_fds = 1; if (tty_fd != -1) { /* the TTY */ ! fdin_mask |= (1 << tty_fd); num_fds = tty_fd +1; } if (cmd_fd != -1) { /* the shell script */ ! fdin_mask |= (1 << cmd_fd); if (cmd_fd > tty_fd) num_fds = cmd_fd +1; tp = &time_out; --- 21,39 ---- ipc_init(tty_fd, cmd_fd) int tty_fd, cmd_fd; { ! fd_set fdout, fdin, fdex; ! FD_ZERO(&fdout); ! FD_ZERO(&fdex); ! FD_ZERO(&fdin_mask); ! FD_SET(0,&fdin_mask); /* the keyboard */ num_fds = 1; if (tty_fd != -1) { /* the TTY */ ! FD_SET(tty_fd,&fdin_mask); num_fds = tty_fd +1; } if (cmd_fd != -1) { /* the shell script */ ! FD_SET(cmd_fd,&fdin_mask); if (cmd_fd > tty_fd) num_fds = cmd_fd +1; tp = &time_out; *************** *** 45,63 **** ipc_poll(tty_fd, cmd_fd) int tty_fd, cmd_fd; { ! int ret_code, fdout, fdin, fdex; ret_code = 0; fdin = fdin_mask; select(num_fds, &fdin, &fdout, &fdex, tp); ! ! if (fdin & 1) ret_code |= KEY_READY; ! if (tty_fd != -1 && (fdin & (1 << tty_fd))) ret_code |= TTY_READY; ! if (cmd_fd != -1 && (fdin & (1 << cmd_fd))) ret_code |= CMD_READY; return(ret_code); --- 47,68 ---- ipc_poll(tty_fd, cmd_fd) int tty_fd, cmd_fd; { ! int ret_code; ! fd_set fdout, fdin, fdex; ret_code = 0; + FD_ZERO(&fdout); + FD_ZERO(&fdex); fdin = fdin_mask; select(num_fds, &fdin, &fdout, &fdex, tp); ! ! if (FD_ISSET(0,&fdin)) ret_code |= KEY_READY; ! if (tty_fd != -1 && FD_ISSET(tty_fd,&fdin)) ret_code |= TTY_READY; ! if (cmd_fd != -1 && FD_ISSET(cmd_fd,&fdin)) ret_code |= CMD_READY; return(ret_code); *************** *** 71,84 **** ipc_update(tty_fd, cmd_fd) int tty_fd, cmd_fd; { ! fdin_mask = 1; num_fds = 1; if (tty_fd != -1) { ! fdin_mask |= (1 << tty_fd); num_fds = tty_fd +1; } if (cmd_fd != -1) { ! fdin_mask |= (1 << cmd_fd); if (cmd_fd > tty_fd) num_fds = cmd_fd +1; tp = &time_out; --- 76,90 ---- ipc_update(tty_fd, cmd_fd) int tty_fd, cmd_fd; { ! FD_ZERO(&fdin_mask); ! FD_SET(0,&fdin_mask); num_fds = 1; if (tty_fd != -1) { ! FD_SET(tty_fd,&fdin_mask); num_fds = tty_fd +1; } if (cmd_fd != -1) { ! FD_SET(cmd_fd,&fdin_mask); if (cmd_fd > tty_fd) num_fds = cmd_fd +1; tp = &time_out; *** chg_dir.c.orig Mon May 17 22:04:49 1993 --- chg_dir.c Mon May 17 22:05:34 1993 *************** *** 56,62 **** return; } ! #ifdef BSD /* * Get the current working directory, AT&T style. Well... not really, it * doesn't handle a NULL pointer for the buffer. --- 56,62 ---- return; } ! #ifdef 0 /*BSD bjm */ /* * Get the current working directory, AT&T style. Well... not really, it * doesn't handle a NULL pointer for the buffer. *** tty_ucb.c.orig Sun Jun 13 23:08:43 1993 --- tty_ucb.c Sun Jun 13 23:08:11 1993 *************** *** 30,35 **** --- 30,36 ---- ioctl(fd, TIOCGETP, &hold); first = 0; } + set_bsd_local(fd); /* get the current settings */ ioctl(fd, TIOCGETP, &tbuf); /* set some beginning values */ *************** *** 117,122 **** --- 118,124 ---- extern int fd; ioctl(fd, TIOCSETP, &hold); + set_bsd_nolocal(fd); return; } *** /dev/null Sun Jun 13 22:45:35 1993 --- fix.c Wed May 19 17:03:53 1993 *************** *** 0 **** --- 1,22 ---- + #include <stdio.h> + #include <sys/termios.h> + + set_bsd_local(fd) + int fd; + { + struct termios t; + + tcgetattr(fd, &t); + t.c_cflag |= CLOCAL; + tcsetattr(fd, TCSANOW, &t); + } + + set_bsd_nolocal(fd) + int fd; + { + struct termios t; + + tcgetattr(fd, &t); + t.c_cflag &= ~CLOCAL; + tcsetattr(fd, TCSANOW, &t); + } -- Bruce Momjian | 830 Blythe Avenue root%candle.uucp@bts.com | Drexel Hill, Pennsylvania 19026 + If your life is a hard drive, | (215) 353-9879(w) + Christ can be your backup. | (215) 853-3000(h)