aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-09-17 13:55:38 +0000
committerChristian Grothoff <christian@grothoff.org>2012-09-17 13:55:38 +0000
commit5c3082ad2c625ad3e676e37853df2d6a60d291ba (patch)
tree1ff69434961ddd0be6836cc6defa3a600b3d0c8c /src
parenta0f18c669ccc260f5aa81fd31b6329b3998a45cc (diff)
downloadgnunet-5c3082ad2c625ad3e676e37853df2d6a60d291ba.tar.gz
gnunet-5c3082ad2c625ad3e676e37853df2d6a60d291ba.zip
-use blocking wait as the pipe might be faster than the process cleanup
Diffstat (limited to 'src')
-rw-r--r--src/util/crypto_rsa.c29
-rw-r--r--src/util/os_priority.c2
2 files changed, 4 insertions, 27 deletions
diff --git a/src/util/crypto_rsa.c b/src/util/crypto_rsa.c
index d94051201..a0a4007bc 100644
--- a/src/util/crypto_rsa.c
+++ b/src/util/crypto_rsa.c
@@ -940,11 +940,7 @@ check_key_generation_completion (void *cls,
940 const struct GNUNET_SCHEDULER_TaskContext *tc) 940 const struct GNUNET_SCHEDULER_TaskContext *tc)
941{ 941{
942 struct GNUNET_CRYPTO_RsaKeyGenerationContext *gc = cls; 942 struct GNUNET_CRYPTO_RsaKeyGenerationContext *gc = cls;
943 enum GNUNET_OS_ProcessStatusType type;
944 unsigned long code;
945 struct GNUNET_CRYPTO_RsaPrivateKey *pk; 943 struct GNUNET_CRYPTO_RsaPrivateKey *pk;
946 char buf[512];
947 ssize_t ret;
948 944
949 gc->read_task = GNUNET_SCHEDULER_NO_TASK; 945 gc->read_task = GNUNET_SCHEDULER_NO_TASK;
950 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 946 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
@@ -953,29 +949,8 @@ check_key_generation_completion (void *cls,
953 GNUNET_CRYPTO_rsa_key_create_stop (gc); 949 GNUNET_CRYPTO_rsa_key_create_stop (gc);
954 return; 950 return;
955 } 951 }
956 if (GNUNET_OK != 952 GNUNET_assert (GNUNET_OK ==
957 GNUNET_OS_process_status (gc->gnunet_rsa, 953 GNUNET_OS_process_wait (gc->gnunet_rsa));
958 &type, &code))
959 {
960 if (0 >= (ret = GNUNET_DISK_file_read (GNUNET_DISK_pipe_handle (gc->gnunet_rsa_out,
961 GNUNET_DISK_PIPE_END_READ),
962 buf, sizeof (buf))))
963 {
964 GNUNET_break (0);
965 gc->cont (gc->cont_cls, NULL, _("internal error"));
966 GNUNET_CRYPTO_rsa_key_create_stop (gc);
967 return;
968 }
969 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
970 _("Unexpected gnunet-rsa output: %.*s\n"),
971 (int) ret, buf);
972 gc->read_task = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
973 GNUNET_DISK_pipe_handle (gc->gnunet_rsa_out,
974 GNUNET_DISK_PIPE_END_READ),
975 &check_key_generation_completion,
976 gc);
977 return;
978 }
979 GNUNET_OS_process_destroy (gc->gnunet_rsa); 954 GNUNET_OS_process_destroy (gc->gnunet_rsa);
980 gc->gnunet_rsa = NULL; 955 gc->gnunet_rsa = NULL;
981 if ( (GNUNET_OS_PROCESS_EXITED != type) || 956 if ( (GNUNET_OS_PROCESS_EXITED != type) ||
diff --git a/src/util/os_priority.c b/src/util/os_priority.c
index 88eee70dd..850378c26 100644
--- a/src/util/os_priority.c
+++ b/src/util/os_priority.c
@@ -1580,6 +1580,8 @@ GNUNET_OS_process_status (struct GNUNET_OS_Process *proc,
1580 1580
1581 GNUNET_assert (0 != proc); 1581 GNUNET_assert (0 != proc);
1582 ret = waitpid (proc->pid, &status, WNOHANG); 1582 ret = waitpid (proc->pid, &status, WNOHANG);
1583 fprintf (stderr, "Waitpid %d returned %d\n",
1584 proc->pid, ret);
1583 if (ret < 0) 1585 if (ret < 0)
1584 { 1586 {
1585 LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 1587 LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "waitpid");