SQLite

Check-in [aab8e7f8d8]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Initialize the random number generator from /dev/urandom, if available. (CVS 2258)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: aab8e7f8d81ffa786d5fae5a13963c6e58a8eefc
User & Date: drh 2005-01-21 17:53:17.000
Context
2005-01-21
18:19
Documentation updates prior to 3.1.0. (CVS 2259) (check-in: fc4f1f13d0 user: drh tags: trunk)
17:53
Initialize the random number generator from /dev/urandom, if available. (CVS 2258) (check-in: aab8e7f8d8 user: drh tags: trunk)
17:07
Change to mkopcodeh.awk to accomodate windows systems. (CVS 2257) (check-in: 39786aa894 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/os_unix.c.
1179
1180
1181
1182
1183
1184
1185
1186


1187
1188
1189




1190
1191
1192
1193
1194
1195
1196
  ** When testing, initializing zBuf[] to zero is all we do.  That means
  ** that we always use the same random number sequence.* This makes the
  ** tests repeatable.
  */
  memset(zBuf, 0, 256);
#if !defined(SQLITE_TEST)
  {
    int pid;


    time((time_t*)zBuf);
    pid = getpid();
    memcpy(&zBuf[sizeof(time_t)], &pid, sizeof(pid));




  }
#endif
  return SQLITE_OK;
}

/*
** Sleep for a little while.  Return the amount of time slept.







|
>
>
|
|
|
>
>
>
>







1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
  ** When testing, initializing zBuf[] to zero is all we do.  That means
  ** that we always use the same random number sequence.* This makes the
  ** tests repeatable.
  */
  memset(zBuf, 0, 256);
#if !defined(SQLITE_TEST)
  {
    int pid, fd;
    fd = open("/dev/urandom", O_RDONLY);
    if( fd<0 ){
      time((time_t*)zBuf);
      pid = getpid();
      memcpy(&zBuf[sizeof(time_t)], &pid, sizeof(pid));
    }else{
      read(fd, zBuf, 256);
      close(fd);
    }
  }
#endif
  return SQLITE_OK;
}

/*
** Sleep for a little while.  Return the amount of time slept.