select() -> poll()

This commit is contained in:
mycroft 2002-09-20 15:15:49 +00:00
parent e59b54da09
commit 1ae4d43ce6
6 changed files with 37 additions and 61 deletions

View File

@ -27,7 +27,7 @@
* i4b daemon - curses fullscreen output
* -------------------------------------
*
* $Id: curses.c,v 1.3 2002/03/27 13:46:35 martin Exp $
* $Id: curses.c,v 1.4 2002/09/20 15:15:49 mycroft Exp $
*
* $FreeBSD$
*
@ -172,8 +172,7 @@ do_menu(void)
WINDOW *menu_w;
int c;
int mpos;
fd_set set;
struct timeval timeout;
struct pollfd set[1];
/* create a new window in the lower screen area */
@ -207,18 +206,15 @@ do_menu(void)
/* input loop */
set[0].fd = STDIN_FILENO;
set[0].events = POLLIN;
for(;;)
{
wrefresh(menu_w);
FD_ZERO(&set);
FD_SET(STDIN_FILENO, &set);
timeout.tv_sec = WMTIMEOUT;
timeout.tv_usec = 0;
/* if no char is available within timeout, exit menu*/
if((select(STDIN_FILENO + 1, &set, NULL, NULL, &timeout)) <= 0)
if((poll(set, 1, WMTIMEOUT * 1000)) <= 0)
goto mexit;
c = wgetch(menu_w);
@ -548,8 +544,7 @@ display_chans(void)
int i, cnt = 0;
WINDOW *chan_w;
int nlines, ncols, pos_x, pos_y;
fd_set set;
struct timeval timeout;
struct pollfd set[1];
struct cfg_entry *cep = NULL;
struct isdn_ctrl_state *ctrl;
@ -647,18 +642,15 @@ display_chans(void)
}
}
set[0].fd = STDIN_FILENO;
set[0].events = POLLIN;
for(;;)
{
wrefresh(chan_w);
FD_ZERO(&set);
FD_SET(STDIN_FILENO, &set);
timeout.tv_sec = WMTIMEOUT;
timeout.tv_usec = 0;
/* if no char is available within timeout, exit menu*/
if((select(STDIN_FILENO + 1, &set, NULL, NULL, &timeout)) <= 0)
if((poll(set, 1, WMTIMEOUT * 1000)) <= 0)
break;
ncols = wgetch(chan_w);
@ -701,8 +693,7 @@ display_cards(void)
{
WINDOW *chan_w;
int nlines, ncols, pos_x, pos_y;
fd_set set;
struct timeval timeout;
struct pollfd set[1];
int i;
struct isdn_ctrl_state *ctrl;
@ -740,12 +731,10 @@ display_cards(void)
wrefresh(chan_w);
FD_ZERO(&set);
FD_SET(STDIN_FILENO, &set);
timeout.tv_sec = WMTIMEOUT*2;
timeout.tv_usec = 0;
set[0].fd = STDIN_FILENO;
set[0].events = POLLIN;
if((select(STDIN_FILENO + 1, &set, NULL, NULL, &timeout)) <= 0)
if((poll(set, 1, WMTIMEOUT*2 * 1000)) <= 0)
{
delwin(chan_w);
return;
@ -763,8 +752,7 @@ display_budget(void)
{
WINDOW *bud_w;
int nlines, ncols, pos_x, pos_y;
fd_set set;
struct timeval timeout;
struct pollfd set[1];
int j;
struct cfg_entry *cep;
time_t now;
@ -867,12 +855,10 @@ display_budget(void)
wrefresh(bud_w);
FD_ZERO(&set);
FD_SET(STDIN_FILENO, &set);
timeout.tv_sec = WMTIMEOUT*3;
timeout.tv_usec = 0;
set[0].fd = STDIN_FILENO;
set[0].events = POLLIN;
if((select(STDIN_FILENO + 1, &set, NULL, NULL, &timeout)) <= 0)
if((poll(set, 1, WMTIMEOUT*3 * 1000)) <= 0)
{
delwin(bud_w);
return;

View File

@ -27,7 +27,7 @@
* i4b daemon - main header file
* -----------------------------
*
* $Id: isdnd.h,v 1.8 2002/04/10 23:35:07 martin Exp $
* $Id: isdnd.h,v 1.9 2002/09/20 15:15:49 mycroft Exp $
*
* $FreeBSD$
*
@ -64,6 +64,7 @@
#include <sys/time.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/poll.h>
#ifdef USE_RTPRIO
#include <sys/rtprio.h>

View File

@ -27,7 +27,7 @@
* i4b daemon - curses fullscreen output
* -------------------------------------
*
* $Id: curses.c,v 1.2 2002/03/27 13:46:35 martin Exp $
* $Id: curses.c,v 1.3 2002/09/20 15:15:49 mycroft Exp $
*
* $FreeBSD$
*
@ -313,8 +313,7 @@ do_menu(void)
WINDOW *menu_w;
int c;
int mpos;
fd_set set;
struct timeval timeout;
struct pollfd set[1];
/* create a new window in the lower screen area */
@ -347,18 +346,15 @@ do_menu(void)
/* input loop */
set[0].fd = STDIN_FILENO;
set[0].events = POLLIN;
for(;;)
{
wrefresh(menu_w);
FD_ZERO(&set);
FD_SET(STDIN_FILENO, &set);
timeout.tv_sec = WMTIMEOUT;
timeout.tv_usec = 0;
/* if no char is available within timeout, exit menu*/
if((select(STDIN_FILENO + 1, &set, NULL, NULL, &timeout)) <= 0)
if((poll(set, 1, WMTIMEOUT * 1000)) <= 0)
goto mexit;
c = wgetch(menu_w);
@ -485,8 +481,7 @@ display_chans(void)
int cnt = 0;
WINDOW *chan_w;
int nlines, ncols, pos_x, pos_y;
fd_set set;
struct timeval timeout;
struct pollfd set[1];
/* need this later to close the connection */
struct ctlr_chan {
@ -578,18 +573,15 @@ display_chans(void)
}
}
set[0].fd = STDIN_FILENO;
set[0].events = POLLIN;
for(;;)
{
wrefresh(chan_w);
FD_ZERO(&set);
FD_SET(STDIN_FILENO, &set);
timeout.tv_sec = WMTIMEOUT;
timeout.tv_usec = 0;
/* if no char is available within timeout, exit menu*/
if((select(STDIN_FILENO + 1, &set, NULL, NULL, &timeout)) <= 0)
if((poll(set, 1, WMTIMEOUT * 1000)) <= 0)
break;
ncols = wgetch(chan_w);

View File

@ -27,7 +27,7 @@
* i4b remote monitor - private header
* -----------------------------------
*
* $Id: monprivate.h,v 1.1.1.1 2001/01/06 13:00:29 martin Exp $
* $Id: monprivate.h,v 1.2 2002/09/20 15:15:49 mycroft Exp $
*
* $FreeBSD$
*
@ -54,6 +54,7 @@
#include <sys/time.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/poll.h>
#endif
/*---------------------------------------------------------------------------*

View File

@ -27,7 +27,7 @@
* isdntel - isdn4bsd telephone answering support
* ==============================================
*
* $Id: defs.h,v 1.1.1.1 2001/01/06 13:00:35 martin Exp $
* $Id: defs.h,v 1.2 2002/09/20 15:15:50 mycroft Exp $
*
* $FreeBSD$
*
@ -52,6 +52,7 @@
#include <sys/dir.h>
#endif
#include <sys/param.h>
#include <sys/poll.h>
#include <netisdn/i4b_ioctl.h>

View File

@ -27,7 +27,7 @@
* isdntel - isdn4bsd telephone answering machine support
* ======================================================
*
* $Id: main.c,v 1.2 2002/02/04 16:48:44 drochner Exp $
* $Id: main.c,v 1.3 2002/09/20 15:15:50 mycroft Exp $
*
* $FreeBSD$
*
@ -56,6 +56,7 @@ main(int argc, char **argv)
{
int i;
int kchar;
struct pollfd set[1];
char *aliasfile = ALIASFILE;
int rrtimeout = REREADTIMEOUT;
@ -112,19 +113,13 @@ main(int argc, char **argv)
/* go into loop */
set[0].fd = STDIN_FILENO;
set[0].events = POLLIN;
for (;;)
{
fd_set set;
struct timeval timeout;
FD_ZERO(&set);
FD_SET(STDIN_FILENO, &set);
timeout.tv_sec = rrtimeout;
timeout.tv_usec = 0;
/* if no char is available within timeout, reread spool */
if((select(STDIN_FILENO + 1, &set, NULL, NULL, &timeout)) <= 0)
if((poll(set, 1, rrtimeout * 1000)) <= 0)
{
reread();
continue;