timer.c (8857) | timer.c (13379) |
---|---|
1/* 2 * PPP Timer Processing Module 3 * 4 * Written by Toshiharu OHNO (tony-o@iij.ad.jp) 5 * 6 * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd. 7 * 8 * Redistribution and use in source and binary forms are permitted 9 * provided that the above copyright notice and this paragraph are 10 * duplicated in all such forms and that any documentation, 11 * advertising materials, and other materials related to such 12 * distribution and use acknowledge that the software was developed 13 * by the Internet Initiative Japan, Inc. The name of the 14 * IIJ may not be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 * | 1/* 2 * PPP Timer Processing Module 3 * 4 * Written by Toshiharu OHNO (tony-o@iij.ad.jp) 5 * 6 * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd. 7 * 8 * Redistribution and use in source and binary forms are permitted 9 * provided that the above copyright notice and this paragraph are 10 * duplicated in all such forms and that any documentation, 11 * advertising materials, and other materials related to such 12 * distribution and use acknowledge that the software was developed 13 * by the Internet Initiative Japan, Inc. The name of the 14 * IIJ may not be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 * |
20 * $Id: timer.c,v 1.3 1995/03/11 15:18:51 amurai Exp $ | 20 * $Id: timer.c,v 1.4 1995/05/30 03:50:59 rgrimes Exp $ |
21 * 22 * TODO: 23 */ 24#include "defs.h" 25#include <sys/time.h> 26#include <signal.h> 27#include "timeout.h" 28#ifdef SIGALRM --- 112 unchanged lines hidden (view full) --- 141void 142TimerService() 143{ 144 struct pppTimer *tp, *exp, *wt; 145 146#ifdef DEBUG 147 ShowTimers(); 148#endif | 21 * 22 * TODO: 23 */ 24#include "defs.h" 25#include <sys/time.h> 26#include <signal.h> 27#include "timeout.h" 28#ifdef SIGALRM --- 112 unchanged lines hidden (view full) --- 141void 142TimerService() 143{ 144 struct pppTimer *tp, *exp, *wt; 145 146#ifdef DEBUG 147 ShowTimers(); 148#endif |
149 if (tp = TimerList) { | 149 tp = TimerList; 150 if (tp) { |
150 tp->rest--; 151 if (tp->rest == 0) { 152 /* 153 * Multiple timers may expires at once. Create list of expired timers. 154 */ 155 exp = NULL; 156 do { 157 tp->state = TIMER_EXPIRED; --- 41 unchanged lines hidden (view full) --- 199 logprintf("---- Begin of Timer Service List---\n"); 200 for (pt = TimerList; pt; pt = pt->next) 201 logprintf("%x: load = %d, rest = %d, state =%x\n", 202 pt, pt->load, pt->rest, pt->state); 203 logprintf("---- End of Timer Service List ---\n"); 204} 205 206#ifdef SIGALRM | 151 tp->rest--; 152 if (tp->rest == 0) { 153 /* 154 * Multiple timers may expires at once. Create list of expired timers. 155 */ 156 exp = NULL; 157 do { 158 tp->state = TIMER_EXPIRED; --- 41 unchanged lines hidden (view full) --- 200 logprintf("---- Begin of Timer Service List---\n"); 201 for (pt = TimerList; pt; pt = pt->next) 202 logprintf("%x: load = %d, rest = %d, state =%x\n", 203 pt, pt->load, pt->rest, pt->state); 204 logprintf("---- End of Timer Service List ---\n"); 205} 206 207#ifdef SIGALRM |
207u_int sleep( u_int sec ) | 208u_int 209sleep( u_int sec ) |
208{ 209 struct timeval to,st,et; 210 long sld, nwd, std; 211 212 gettimeofday( &st, NULL ); 213 to.tv_sec = sec; 214 to.tv_usec = 0; 215 std = st.tv_sec * 1000000 + st.tv_usec; --- 10 unchanged lines hidden (view full) --- 226 else 227 sld = 1; /* Avoid both tv_sec/usec is 0 */ 228 229 /* Calculate timeout value for select */ 230 to.tv_sec = sld / 1000000; 231 to.tv_usec = sld % 1000000; 232 } 233 } | 210{ 211 struct timeval to,st,et; 212 long sld, nwd, std; 213 214 gettimeofday( &st, NULL ); 215 to.tv_sec = sec; 216 to.tv_usec = 0; 217 std = st.tv_sec * 1000000 + st.tv_usec; --- 10 unchanged lines hidden (view full) --- 228 else 229 sld = 1; /* Avoid both tv_sec/usec is 0 */ 230 231 /* Calculate timeout value for select */ 232 to.tv_sec = sld / 1000000; 233 to.tv_usec = sld % 1000000; 234 } 235 } |
236 return (0L); |
|
234} 235 236void usleep( u_int usec) 237{ 238 struct timeval to,st,et; 239 long sld, nwd, std; 240 241 gettimeofday( &st, NULL ); --- 46 unchanged lines hidden --- | 237} 238 239void usleep( u_int usec) 240{ 241 struct timeval to,st,et; 242 long sld, nwd, std; 243 244 gettimeofday( &st, NULL ); --- 46 unchanged lines hidden --- |