diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-08-05 11:07:20 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-08-05 11:07:20 +0200 |
commit | 453d984569c17c22fecd56d9f2deb14cc59cdf93 (patch) | |
tree | d081a93ae5c4f8dd22e06c7552a5032ddb45be38 /src/util/crypto_helper_denom.c | |
parent | 1ca5213894e9852bbc5a069b11e1e17d1038f1a5 (diff) |
-try to fix Florian's FIXME/endless loop, alas without test as Florian did not provide enough details for that
Diffstat (limited to 'src/util/crypto_helper_denom.c')
-rw-r--r-- | src/util/crypto_helper_denom.c | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/src/util/crypto_helper_denom.c b/src/util/crypto_helper_denom.c index 93b5211e2..f55d2cd82 100644 --- a/src/util/crypto_helper_denom.c +++ b/src/util/crypto_helper_denom.c @@ -145,28 +145,19 @@ try_connect (struct TALER_CRYPTO_DenominationHelper *dh) /* Fix permissions on client UNIX domain socket, just in case umask() is not set to enable group write */ { - char path[sizeof (dh->my_sa) + 1]; + char path[sizeof (dh->my_sa.sun_path) + 1]; strncpy (path, - (const char *) &dh->my_sa, - sizeof (dh->my_sa)); - path[sizeof (dh->my_sa)] = '\0'; + dh->my_sa.sun_path, + sizeof (path) - 1); + path[sizeof (dh->my_sa.sun_path)] = '\0'; + if (0 != chmod (path, + S_IRUSR | S_IWUSR | S_IWGRP)) { - char path[sizeof (dh->sa.sun_path) + 1]; - - strncpy (path, - dh->my_sa.sun_path, - sizeof (dh->my_sa.sun_path)); - path[sizeof (dh->my_sa.sun_path)] = '\0'; - - if (0 != chmod (path, - S_IRUSR | S_IWUSR | S_IWGRP)) - { - GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, - "chmod", - path); - } + GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, + "chmod", + path); } } GNUNET_free (tmpdir); @@ -445,6 +436,7 @@ TALER_CRYPTO_helper_denom_poll (struct TALER_CRYPTO_DenominationHelper *dh) ssize_t ret; const struct GNUNET_MessageHeader *hdr = (const struct GNUNET_MessageHeader *) buf; + int flag = MSG_DONTWAIT; try_connect (dh); if (-1 == dh->sock) @@ -454,11 +446,14 @@ TALER_CRYPTO_helper_denom_poll (struct TALER_CRYPTO_DenominationHelper *dh) ret = recv (dh->sock, buf, sizeof (buf), - MSG_DONTWAIT); + flag); if (ret < 0) { if (EAGAIN == errno) { + /* EAGAIN should only happen if we did not + already go through this loop */ + GNUNET_assert (0 != flag); if (dh->synced) break; if (! await_read_ready (dh)) @@ -471,7 +466,7 @@ TALER_CRYPTO_helper_denom_poll (struct TALER_CRYPTO_DenominationHelper *dh) if (-1 == dh->sock) return; /* give up */ } - /* FIXME: We should not retry infinitely */ + flag = 0; /* syscall must be non-blocking this time */ continue; /* try again */ } GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, @@ -480,6 +475,7 @@ TALER_CRYPTO_helper_denom_poll (struct TALER_CRYPTO_DenominationHelper *dh) return; } + flag = MSG_DONTWAIT; if ( (ret < sizeof (struct GNUNET_MessageHeader)) || (ret != ntohs (hdr->size)) ) { |