1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-01-25 19:46:21 +00:00

Rework handling of I/O via select() to use correct fd_set type instead of int for fd sets.

Some code that was maintaining an fd_set with only a single fd was replaced
       with just the fd as int, which can be added to the global fd_set as needed.
       More testing is required for less usual configurations such as host TCP/UDP/IP
       and direct ethernet (packet filter or NIT) I/O.

	modified:   src/common.c
	modified:   src/ether.c
	modified:   src/inet.c
	modified:   src/initkbd.c
	modified:   src/kbdsubrs.c
	modified:   src/keyevent.c
	modified:   src/main.c
	modified:   src/osmsg.c
	modified:   src/rawrs232c.c
	modified:   src/rpc.c
	modified:   src/rs232c.c
	modified:   src/tty.c
	modified:   src/uraid.c
	modified:   src/xinit.c
This commit is contained in:
Nick Briggs
2020-12-08 19:26:56 -08:00
parent ba0a42f663
commit b234064d91
14 changed files with 117 additions and 94 deletions

View File

@@ -24,6 +24,7 @@ static char *id = "$Id: osmsg.c,v 1.2 1999/01/03 02:07:29 sybalsky Exp $ Copyrig
#include <pwd.h>
#include <sys/types.h>
#include <sys/select.h>
#include <unistd.h>
#ifdef ISC
#include <sys/bsdtypes.h>
@@ -79,7 +80,7 @@ int previous_size;
int logChanged; /* T if log file has changed since last READ */
/* Set by flush_pty, to avoid the stat call */
u_int LogFileFd;
extern u_int LispReadFds;
extern fd_set LispReadFds;
/************************************************************************/
/* */
@@ -162,7 +163,7 @@ gotpty:
if ((log_id = open(logfile, (O_RDWR | O_CREAT), 0666)) < 0) return;
#ifdef LOGINT
LogFileFd = 1 << cons_pty;
LogFileFd = cons_pty; /* was kept as an fd_set, but doesn't need to be */
flags = fcntl(cons_pty, F_GETFL, 0);
flags = fcntl(cons_pty, F_SETFL, (flags | FASYNC | FNDELAY));
if (fcntl(cons_pty, F_SETOWN, getpid()) == -1) {
@@ -170,7 +171,7 @@ gotpty:
perror("fcntl F_SETOWN of log PTY");
#endif
};
LispReadFds |= LogFileFd;
FD_SET(LogFileFd, &LispReadFds);
flush_pty();
#endif
previous_size = 0;
@@ -344,7 +345,7 @@ LispPTR flush_pty() {
struct stat sbuf;
char buf[MESSAGE_BUFFER_SIZE]; /* Buffer between pty and log file */
int size;
static int rfds;
static fd_set rfds;
int rval;
struct statfs fsbuf;
@@ -352,10 +353,10 @@ LispPTR flush_pty() {
DBPRINT(("flush_pty() called.\n"));
/* polling pty nd flush os message to log file */
#ifndef LOGINT
rfds = (1 << cons_pty);
if (select(32, &rfds, NULL, NULL, &selecttimeout) < 0) return (NIL);
FD_SET(cons_pty, &rfds);
if (select(32, &rfds, NULL, NULL, &selecttimeout) <= 0) return (NIL);
if ((cons_pty >= 0) && (rfds & (1 << cons_pty)))
if ((cons_pty >= 0) && FD_ISSET(cons_pty, rfds))
#else /* LOGINT */
if ((cons_pty >= 0) && ((size = read(cons_pty, buf, MESSAGE_BUFFER_SIZE - 1)) > 0))