Reimplement max_idle without a separate thread
Remove the KillIdle thread. Add timeout to struct iop, initialized in io_open(). Obey it in io_input() by passing it to empth_select(). If empth_select() times out, report that back through io_input() to recvclient() and player_login(). If player_login() receives a timeout indication, print a message and terminate the session. If recvclient() receives a timeout indication, flash a message to the player and initiate a shut down the player's session. Create WIN32 sys/time.h to define struct timeval. This creates some conflicts with WIN32 windows.h definitions. Including windows.h in show.c and info.c creates conflicts, so remove that. Modify service.c to include sys/socket.h instead of windows.h to remove the conflict with sys/time.h.
This commit is contained in:
parent
a7ee69d112
commit
08b9455682
17 changed files with 181 additions and 133 deletions
|
@ -33,6 +33,7 @@
|
|||
|
||||
#ifndef EMPIO_H
|
||||
#define EMPIO_H
|
||||
#include <sys/time.h>
|
||||
|
||||
#define IO_READ 0x1
|
||||
#define IO_WRITE 0x2
|
||||
|
@ -46,7 +47,7 @@
|
|||
#define IO_NOWAIT 0
|
||||
#define IO_WAIT 1
|
||||
|
||||
extern struct iop *io_open(int, int, int);
|
||||
extern struct iop *io_open(int, int, int, struct timeval);
|
||||
extern void io_init(void);
|
||||
extern int io_noblocking(struct iop *, int);
|
||||
extern void io_close(struct iop *);
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#ifndef EMPTHREAD_H
|
||||
#define EMPTHREAD_H
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
|
||||
#ifdef EMPTH_LWP
|
||||
|
@ -168,10 +169,13 @@ void empth_terminate(empth_t *thread);
|
|||
* If FLAGS & EMPTH_FD_READ, wake up if FD is ready for input.
|
||||
* If FLAGS & EMPTH_FD_WRITE, wake up if FD is ready for output.
|
||||
* At most one thread may sleep on the same file descriptor.
|
||||
* TIMEOUT, if non-null, limits the sleep time.
|
||||
* Return one when the FD is ready, zero on timeout, -1 on error with
|
||||
* errno set.
|
||||
* Note: Currently, Empire sleeps only on network I/O, i.e. FD is a
|
||||
* socket. Implementations should not rely on that.
|
||||
*/
|
||||
void empth_select(int fd, int flags);
|
||||
int empth_select(int fd, int flags, struct timeval *timeout);
|
||||
|
||||
/*
|
||||
* Awaken THREAD if it is sleeping in empth_select() or empth_sleep().
|
||||
|
|
|
@ -45,7 +45,7 @@ struct lwpProc *lwpCreate(int prio, void (*)(void *), int size,
|
|||
void lwpExit(void);
|
||||
void lwpTerminate(struct lwpProc * p);
|
||||
void lwpYield(void);
|
||||
void lwpSleepFd(int fd, int flags);
|
||||
int lwpSleepFd(int fd, int flags, struct timeval *timeout);
|
||||
int lwpSleepUntil(time_t until);
|
||||
void lwpWakeup(struct lwpProc *);
|
||||
int lwpSigWait(sigset_t *set, int *sig);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue