gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-taler-mdb] branch master updated (1e464cb -> 5e1227f)


From: gnunet
Subject: [taler-taler-mdb] branch master updated (1e464cb -> 5e1227f)
Date: Fri, 24 Jan 2020 12:27:57 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a change to branch master
in repository taler-mdb.

    from 1e464cb  rename: TALER_config_get_denom->amount
     new 237dbf9  improve MDB termination logic
     new 5e1227f  merge

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/main.c | 41 +++++++++++++++++++++++++++++++++--------
 1 file changed, 33 insertions(+), 8 deletions(-)

diff --git a/src/main.c b/src/main.c
index 96c26df..2127a7b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,6 +1,6 @@
 /*
  This file is part of TALER
- Copyright (C) 2019 GNUnet e.V.
+ Copyright (C) 2019, 2020 Taler Systems SA
 
  TALER is free software; you can redistribute it and/or modify it under the
  terms of the GNU General Public License as published by the Free Software
@@ -18,7 +18,7 @@ along with
 */
 /**
 * @file main.c
-* @brief main functionality of the application
+* @brief runs the payment logic for a Taler-enabled snack machine
 * @author Marco Boss
 * @author Christian Grothoff
 * @author Dominik Hofer
@@ -230,6 +230,13 @@ along with
 #define READER_SESSION_CANCEL_REQUEST "04"
 #define READER_REVALUE_DENIED "0E"
 
+/**
+ * How long are we willing to wait for MDB during
+ * shutdown?
+ */
+#define SHUTDOWN_MDB_TIMEOUT GNUNET_TIME_relative_multiply ( \
+    GNUNET_TIME_UNIT_MILLISECONDS, 100)
+
 /**
  * Datatype for mdb subcommands and data
  */
@@ -499,6 +506,8 @@ struct CancelButton
    */
   int cancelbuttonfd;
 };
+
+
 /**
  * DLL of pending refund operations.
  */
@@ -547,6 +556,12 @@ static int global_ret;
  */
 static int in_shutdown;
 
+/**
+ * Flag set to remember that MDB needs shutdown
+ * (because we were actually able to talk to MDB).
+ */
+static int mdb_active;
+
 /**
  * Reference to the keyboard task
  */
@@ -697,8 +712,11 @@ static char backlight_on = '1';
  */
 static char backlight_off = '0';
 
-
+/**
+ * State for the implementation of the 'cancel' button.
+ */
 static struct CancelButton cancelButton;
+
 /**
  * Name of the UART device with the MDB (i.e. /dev/ttyAMA0).
  */
@@ -1008,6 +1026,7 @@ shutdown_task (void *cls)
   in_shutdown = GNUNET_YES;
   mdb.cmd = &endSession;
   run_mdb_event_loop ();
+
   if (NULL != ctx)
   {
     GNUNET_CURL_fini (ctx);
@@ -1870,13 +1889,15 @@ write_mdb_command (void *cls)
     run_mdb_event_loop ();
     return;
   }
-  /* if command was sent completely send the rest */
+  /* if command was sent partially, send the rest */
   if (mdb.tx_off < mdb.tx_len)
   {
     ssize_t ret = write (mdb.uartfd,
                          &mdb.txBuffer[mdb.tx_off],
                          mdb.tx_len - mdb.tx_off);
-
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Wrote %d bytes to MDB\n",
+                (int) ret);
     did_write = 1;
     if (-1 == ret)
     {
@@ -1944,7 +1965,7 @@ write_mdb_command (void *cls)
       chkSum += mdb.txBuffer[idx] = mdb.cmd->cmd.bin[idx];
     for (size_t idx = 0; idx < mdb.cmd->data.bin_size; idx++)
       chkSum += mdb.txBuffer[idx + mdb.cmd->cmd.bin_size] =
-        mdb.cmd->data.bin[idx];
+                  mdb.cmd->data.bin[idx];
     mdb.txBuffer[mdb.cmd->cmd.bin_size + mdb.cmd->data.bin_size] =
       (uint8_t) (chkSum & 0xFF);
   }
@@ -2384,6 +2405,7 @@ read_mdb_command (void *cls)
 
   while (mdb.rx_off > 0)
   {
+    mdb_active = GNUNET_YES;
     /* find begining of command */
     for (cmdStartIdx = 0; cmdStartIdx < mdb.rx_off; cmdStartIdx++)
       if (VMC_CMD_START == mdb.rxBuffer[cmdStartIdx])
@@ -2456,11 +2478,14 @@ run_mdb_event_loop ()
          (in_shutdown) ||
          (mdb.tx_len > mdb.tx_off) ) )
   {
-    if (disable_mdb)
+    if (disable_mdb || ! mdb_active)
       mdb.wtask = GNUNET_SCHEDULER_add_now (&write_mdb_command,
                                             NULL);
     else
-      mdb.wtask = GNUNET_SCHEDULER_add_write_file 
(GNUNET_TIME_UNIT_FOREVER_REL,
+      mdb.wtask = GNUNET_SCHEDULER_add_write_file ((in_shutdown)
+                                                   ? SHUTDOWN_MDB_TIMEOUT
+                                                   :
+                                                   
GNUNET_TIME_UNIT_FOREVER_REL,
                                                    &fh,
                                                    &write_mdb_command,
                                                    NULL);

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]