mirror of
https://github.com/Interlisp/maiko.git
synced 2026-02-27 00:59:46 +00:00
Correct async I/O setup to work for Solaris (#446)
Solaris does not define O_ASYNC, but does define FASYNC and FNDELAY, which it expects to be used in place of O_ASYNC in an fcntl() to set up asynchronous I/O on a socket. This fix also generates a compiler warning if neither the O_ASYNC nor FASYNC/FNDELAY methods are available.
This commit is contained in:
15
src/timer.c
15
src/timer.c
@@ -25,6 +25,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
@@ -490,21 +491,29 @@ static void int_timer_init()
|
||||
|
||||
void int_io_open(int fd)
|
||||
{
|
||||
DBPRINT(("int_io_open %d\n", fd));
|
||||
#ifdef DOS
|
||||
/* would turn on DOS kbd signal handler here */
|
||||
#elseif defined(O_ASYNC)
|
||||
DBPRINT(("int_io_opening %d\n", fd));
|
||||
#elif defined(O_ASYNC)
|
||||
if (fcntl(fd, F_SETOWN, getpid()) == -1) perror("fcntl F_SETOWN error");
|
||||
if (fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_ASYNC) == -1) perror("fcntl F_SETFL on error");
|
||||
#elif defined(FASYNC) && defined(FNDELAY)
|
||||
if (fcntl(fd, F_SETOWN, getpid()) == -1) perror("fcntl F_SETOWN error");
|
||||
if (fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | FNDELAY | FASYNC) == -1) perror("fcntl F_SETFL on error");
|
||||
#else
|
||||
#warning "No async i/o can be enabled - investigate and remedy this"
|
||||
#endif
|
||||
}
|
||||
|
||||
void int_io_close(int fd)
|
||||
{
|
||||
DBPRINT(("int_io_close %d\n", fd));
|
||||
#ifdef DOS
|
||||
/* Turn off signaller here */
|
||||
#elseif defined(O_ASYNC)
|
||||
#elif defined(O_ASYNC)
|
||||
if (fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) & ~O_ASYNC) == -1) perror("fcntl_F_SETFL off error");
|
||||
#elif defined(FASYNC) && defined(FNDELAY)
|
||||
if (fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) & ~(FNDELAY | FASYNC)) == -1) perror("fcntl F_SETFL off error");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user