pike.git / src / builtin.cmod

version» Context lines:

pike.git/src/builtin.cmod:2339:    Pike_error("Failed to set up Crypto Service.\n");    }       struct pike_string *ret = begin_shared_string(len);    if( !CryptGenRandom(crypto_handle, len, (BYTE*)ret->str) )    {    do_free_unlinked_pike_string (ret);    Pike_error("Failed to create random data.\n");    }   #else /* !__NT__ */ -  if( random_fd==-1 ) +  while( random_fd == -1 )    {    random_fd = open("/dev/urandom", O_RDONLY); -  if( random_fd==-1 ) +  if( random_fd==-1 ) { +  if (errno == EINTR) continue; /* Retry */    Pike_error("Failed to open /dev/urandom.\n");    } -  +  }       struct pike_string *ret = begin_shared_string(len);    char* str = ret->str;    while( len )    {    int sz = read(random_fd, str, len);    if (sz < 0) { -  +  if (errno == EINTR) continue; /* Retry */ +     free_string(ret);       /* Attempt to recover on next call. */    close(random_fd);    random_fd = -1;       Pike_error("Failed to read %d bytes from /dev/urandom.\n", len);    }    str += sz;    len -= sz;