* Written by Tim Wilkinson <tim@tjwassoc.demon.co.uk>, 1996.
*/
-#define DBG(s)
-
-#include "config.h"
-
-#include "defines.h"
+#include <stdio.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <assert.h>
#include <unistd.h>
+#include "config.h"
#include "thread.h"
-/*
- * We only need this stuff is we are using the internal thread system.
- */
-#if defined(USE_INTERNAL_THREADS)
#define TH_READ 0
#define TH_WRITE 1
static fd_set writesPending;
static thread* readQ[FD_SETSIZE];
static thread* writeQ[FD_SETSIZE];
-static struct timeval tm = { 0, 0 };
void blockOnFile(int, int);
void waitOnEvents(void);
{
#if !defined(BLOCKING_CALLS)
int r;
+#if defined(HAVE_IOCTL) && defined(FIOASYNC)
int on = 1;
+#endif
int pid;
/* Make non-blocking */
void clear_thread_flags(void)
{
#if !defined(BLOCKING_CALLS)
- int fl, fd;
-
#if defined(HAVE_FCNTL) && defined(O_NONBLOCK)
- fd = fileno(stdin);
+ int fl, fd;
+
+ fd = fileno(stdin);
fl = fcntl(fd, F_GETFL, 0);
fl = fcntl(fd, F_SETFL, fl & (~O_NONBLOCK));
- fd = fileno(stdout);
+ fd = fileno(stdout);
fl = fcntl(fd, F_GETFL, 0);
fl = fcntl(fd, F_SETFL, fl & (~O_NONBLOCK));
- fd = fileno(stderr);
+ fd = fileno(stderr);
fl = fcntl(fd, F_GETFL, 0);
fl = fcntl(fd, F_SETFL, fl & (~O_NONBLOCK));
+
#elif defined(HAVE_IOCTL) && defined(FIONBIO)
- fl = 0;
- fd = fileno(stdin);
+ int fl, fd;
+
+ fl = 0;
+ fd = fileno(stdin);
(void) ioctl(fd, FIONBIO, &fl);
- fd = fileno(stdout);
+ fd = fileno(stdout);
(void) ioctl(fd, FIONBIO, &fl);
- fd = fileno(stderr);
+ fd = fileno(stderr);
(void) ioctl(fd, FIONBIO, &fl);
#endif
-
#endif
-fflush (stdout);
-fflush (stderr);
+
+ fflush(stdout);
+ fflush(stderr);
}
threadedSocket(int af, int type, int proto)
{
int fd;
- int r;
- int on = 1;
- int pid;
fd = socket(af, type, proto);
return (threadedFileDescriptor(fd));
threadedOpen(char* path, int flags, int mode)
{
int fd;
- int r;
- int on = 1;
- int pid;
fd = open(path, flags, mode);
return (threadedFileDescriptor(fd));
threadedAccept(int fd, struct sockaddr* addr, int* len)
{
int r;
- int on = 1;
for (;;)
{
assert(blockInts > 0);
-DBG( printf("checkEvents block:%d\n", block); )
+ DBG( printf("checkEvents block:%d\n", block); )
if (sleepThreads != 0)
{
*/
assert(blockInts > 0);
-DBG( printf("Select returns %d\n", r); )
+ DBG( printf("Select returns %d\n", r); )
/* Some threads may have finished sleeping.
*/
}
}
}
-#endif