Browse Source

Using errno to detect ethash_io failures

- Printf debug output is still printed by ethash itself unless one
  compiles with -DETHASH_NO_CRITICAL_OUTPUT.
cl-refactor
Lefteris Karapetsas 10 years ago
parent
commit
d4a4b6e285
  1. 1
      internal.c
  2. 3
      io.c
  3. 4
      io.h

1
internal.c

@ -364,6 +364,7 @@ static bool ethash_mmap(struct ethash_full* ret, FILE* f)
{
int fd;
char* mmapped_data;
errno = 0;
ret->file = f;
if ((fd = ethash_fileno(ret->file)) == -1) {
return false;

3
io.c

@ -21,6 +21,7 @@
#include "io.h"
#include <string.h>
#include <stdio.h>
#include <errno.h>
enum ethash_io_rc ethash_io_prepare(
char const* dirname,
@ -32,6 +33,8 @@ enum ethash_io_rc ethash_io_prepare(
{
char mutable_name[DAG_MUTABLE_NAME_MAX_SIZE];
enum ethash_io_rc ret = ETHASH_IO_FAIL;
// reset errno before io calls
errno = 0;
// assert directory exists
if (!ethash_mkdir(dirname)) {

4
io.h

@ -59,6 +59,7 @@ enum ethash_io_rc {
* figure out what kind of problem (I/O, memory e.t.c.) causes a NULL
* ethash_full_t
*/
#ifndef ETHASH_NO_CRITICAL_OUTPUT
#define ETHASH_CRITICAL(...) \
do \
{ \
@ -66,6 +67,9 @@ enum ethash_io_rc {
printf("\n"); \
fflush(stdout); \
} while (0)
#else
#define ETHASH_CRITICAL(...)
#endif
/**
* Prepares io for ethash

Loading…
Cancel
Save