00001
00002
00003
00004
00005
00006
00007
00008 #include "config.h"
00009
00010 #ifndef lint
00011 static const char revid[] = "$Id: os__sleep_8c-source.html,v 1.1 2008/06/08 10:21:31 sebdiaz Exp $";
00012 #endif
00013
00014 #ifndef NO_SYSTEM_INCLUDES
00015 #include <sys/types.h>
00016
00017 #ifdef HAVE_SYS_SELECT_H
00018 #include <sys/select.h>
00019 #endif
00020
00021 #ifdef HAVE_VXWORKS
00022 #include <sys/times.h>
00023 #include <time.h>
00024 #else
00025 #if TIME_WITH_SYS_TIME
00026 #include <sys/time.h>
00027 #include <time.h>
00028 #else
00029 #if HAVE_SYS_TIME_H
00030 #include <sys/time.h>
00031 #else
00032 #include <time.h>
00033 #endif
00034 #endif
00035 #endif
00036
00037 #include <string.h>
00038 #include <unistd.h>
00039 #endif
00040
00041 #include "db_int.h"
00042 #include "os_jump.h"
00043
00044
00045
00046
00047
00048
00049
00050 int
00051 CDB___os_sleep(dbenv, secs, usecs)
00052 DB_ENV *dbenv;
00053 u_long secs, usecs;
00054 {
00055 struct timeval t;
00056 int ret;
00057
00058
00059 for (; usecs >= 1000000; usecs -= 1000000)
00060 ++secs;
00061
00062 if (CDB___db_jump.j_sleep != NULL)
00063 return (CDB___db_jump.j_sleep(secs, usecs));
00064
00065
00066
00067
00068
00069 t.tv_sec = secs;
00070 t.tv_usec = usecs;
00071 ret = select(0, NULL, NULL, NULL, &t) == -1 ? CDB___os_get_errno() : 0;
00072
00073 if (ret != 0)
00074 CDB___db_err(dbenv, "select: %s", strerror(ret));
00075
00076 return (ret);
00077 }