[git] GpgOL - branch, master, updated. gpgol-2.3.0-40-gb4a65a8

by Andre Heinecke cvs at cvs.gnupg.org
Mon Sep 24 12:04:30 CEST 2018


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GnuPG extension for MS Outlook".

The branch, master has been updated
       via  b4a65a8eda8fabd73bc2cf7db2d7084194089125 (commit)
       via  19f8d131b3bb48eb60a4a6d6c01ac5c4c97e35ab (commit)
       via  98439ec3551084153e52b25f069d7170d1db5e6f (commit)
       via  da75bcaa1fc935aa4a770b41e36ce2ce7a218db3 (commit)
       via  296a4d74725cab076ba714564754148fa783da0f (commit)
       via  177b72b8c33a2459e20695e01492573211c150f8 (commit)
       via  5156d7b1da1fd9463e9442f5e913b6b24c0a7b69 (commit)
      from  635ff920f8c22087d27b62f8a597fe36e9925ff8 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit b4a65a8eda8fabd73bc2cf7db2d7084194089125
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Mon Sep 24 12:03:33 2018 +0200

    Remove obsolete / unused code
    
    * src/exechelp.c, src/exechelp.h: Removed.
    * src/Makefile.am: Update accordingly.
    
    --
    We use GpgME spawning nowadays.

diff --git a/src/Makefile.am b/src/Makefile.am
index 47643fa..0993bd5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -40,7 +40,6 @@ gpgol_SOURCES = \
     dispcache.h dispcache.cpp \
     eventsink.h \
     eventsinks.h \
-    exechelp.c exechelp.h \
     explorer-events.cpp \
     explorers-events.cpp \
     filetype.c filetype.h \
diff --git a/src/exechelp.c b/src/exechelp.c
deleted file mode 100644
index acae01d..0000000
--- a/src/exechelp.c
+++ /dev/null
@@ -1,150 +0,0 @@
-/* exechelp.c - fork and exec helpers
- * Copyright (C) 2004, 2007, 2014 g10 Code GmbH
- * Copyright (C) 2015 by Bundesamt für Sicherheit in der Informationstechnik
- * Software engineering by Intevation GmbH
- *
- * This file is part of GpgOL.
- *
- * GpgOL 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 Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * GpgOL is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <windows.h>
-
-#include <gpg-error.h>
-
-#include "common.h"
-#include "exechelp.h"
-
-/* Define to 1 do enable debugging.  */
-#define DEBUG_W32_SPAWN 0
-
-
-

-
-/* Lock a spawning process.  The caller needs to provide the address
-   of a variable to store the lock information and the name or the
-   process.  */
-gpg_error_t
-gpgol_lock_spawning (lock_spawn_t *lock)
-{
-  int waitrc;
-  int timeout = 5;
-
-  *lock = CreateMutexW (NULL, FALSE, L"spawn_gnupg_uiserver_sentinel");
-  if (!*lock)
-    {
-      log_error ("failed to create the spawn mutex: rc=%ld", GetLastError ());
-      return gpg_error (GPG_ERR_GENERAL);
-    }
-
- retry:
-  waitrc = WaitForSingleObject (*lock, 1000);
-  if (waitrc == WAIT_OBJECT_0)
-    return 0;
-
-  if (waitrc == WAIT_TIMEOUT && timeout)
-    {
-      timeout--;
-      goto retry;
-    }
-  if (waitrc == WAIT_TIMEOUT)
-    log_error ("error waiting for the spawn mutex: timeout");
-  else
-    log_error ("error waiting for the spawn mutex: (code=%d) rc=%ld",
-                waitrc, GetLastError ());
-  return gpg_error (GPG_ERR_GENERAL);
-}
-
-
-/* Unlock the spawning process.  */
-void
-gpgol_unlock_spawning (lock_spawn_t *lock)
-{
-  if (*lock)
-    {
-      if (!ReleaseMutex (*lock))
-        log_error ("failed to release the spawn mutex: rc=%ld", GetLastError());
-      CloseHandle (*lock);
-      *lock = NULL;
-    }
-}
-
-
-/* Fork and exec the program with /dev/null as stdin, stdout and
-   stderr.  Returns 0 on success or an error code.  */
-gpg_error_t
-gpgol_spawn_detached (const char *cmdline)
-{
-  SECURITY_ATTRIBUTES sec_attr;
-  PROCESS_INFORMATION pi =
-    {
-      NULL,      /* Returns process handle.  */
-      0,         /* Returns primary thread handle.  */
-      0,         /* Returns pid.  */
-      0          /* Returns tid.  */
-    };
-  STARTUPINFO si;
-  int cr_flags;
-
-  log_debug ("gpgol_spawn_detached cmdline=%s", cmdline);
-
-  /* Prepare security attributes.  */
-  memset (&sec_attr, 0, sizeof sec_attr);
-  sec_attr.nLength = sizeof sec_attr;
-  sec_attr.bInheritHandle = FALSE;
-
-  /* Start the process.  Note that we can't run the PREEXEC function
-     because this would change our own environment. */
-  memset (&si, 0, sizeof si);
-  si.cb = sizeof (si);
-  si.dwFlags = STARTF_USESHOWWINDOW;
-  si.wShowWindow = DEBUG_W32_SPAWN ? SW_SHOW : SW_MINIMIZE;
-
-  cr_flags = (CREATE_DEFAULT_ERROR_MODE
-              | GetPriorityClass (GetCurrentProcess ())
-              | CREATE_NEW_PROCESS_GROUP
-              | DETACHED_PROCESS);
-
-  if (!CreateProcess (NULL,          /* pgmname; Program to start.  */
-                      (char *) cmdline, /* Command line arguments.  */
-                      &sec_attr,     /* Process security attributes.  */
-                      &sec_attr,     /* Thread security attributes.  */
-                      TRUE,          /* Inherit handles.  */
-                      cr_flags,      /* Creation flags.  */
-                      NULL,          /* Environment.  */
-                      NULL,          /* Use current drive/directory.  */
-                      &si,           /* Startup information. */
-                      &pi            /* Returns process information.  */
-                      ))
-    {
-      log_error ("CreateProcess failed: %ld\n", GetLastError ());
-      return gpg_error (GPG_ERR_GENERAL);
-    }
-
-  /* Process has been created suspended; resume it now. */
-  CloseHandle (pi.hThread);
-  CloseHandle (pi.hProcess);
-
-  return 0;
-}
diff --git a/src/exechelp.h b/src/exechelp.h
deleted file mode 100644
index 6b62407..0000000
--- a/src/exechelp.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* exechelp.h - fork and exec helpers
- * Copyright (C) 2004, 2007 g10 Code GmbH
- * Copyright (C) 2015 by Bundesamt für Sicherheit in der Informationstechnik
- * Software engineering by Intevation GmbH
- *
- * This file is part of GpgOL.
- *
- * GpgOL 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 Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * GpgOL is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- */
-
-#ifndef GPGOL_EXECHELP_H
-#define GPGOL_EXECHELP_H
-
-#include <gpg-error.h>
-
-#ifdef __cplusplus
-extern "C" {
-#if 0
-}
-#endif
-#endif
-
-#define lock_spawn_t HANDLE
-
-gpg_error_t gpgol_lock_spawning (lock_spawn_t *lock);
-void gpgol_unlock_spawning (lock_spawn_t *lock);
-
-/* Fork and exec CMDLINE with /dev/null as stdin, stdout and stderr.
-   Returns 0 on success or an error code.  */
-gpg_error_t gpgol_spawn_detached (const char *cmdline);
-
-#ifdef __cplusplus
-#if 0
-{
-#endif
-}
-#endif
-
-#endif /* GPGOL_EXECHELP_H */

commit 19f8d131b3bb48eb60a4a6d6c01ac5c4c97e35ab
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Mon Sep 24 11:50:25 2018 +0200

    Add string pseudonyms for debug output
    
    * src/debug.cpp (anonstr): New.
    
    --
    If DBG_DATA is disabled this will pseudonym strings
    in debug output.

diff --git a/src/debug.cpp b/src/debug.cpp
index b268e86..de1108d 100644
--- a/src/debug.cpp
+++ b/src/debug.cpp
@@ -19,6 +19,10 @@
 
 #include "common_indep.h"
 
+#include <gpg-error.h>
+
+#include <string>
+#include <unordered_map>
 
 /* The malloced name of the logfile and the logging stream.  If
    LOGFILE is NULL, no logging is done. */
@@ -304,3 +308,45 @@ log_window_hierarchy (HWND window, const char *fmt, ...)
     }
 }
 #endif
+
+GPGRT_LOCK_DEFINE (anon_str_lock);
+
+/* Weel ok this survives unload but we don't want races
+   and it makes a bit of sense to keep the strings constant. */
+static std::unordered_map<std::string, std::string> str_map;
+
+const char *anonstr (const char *data)
+{
+  static int64_t cnt;
+  if (opt.enable_debug & DBG_DATA)
+    {
+      return data;
+    }
+  if (!data)
+    {
+      return "gpgol_str_null";
+    }
+  if (!strlen (data))
+    {
+      return "gpgol_str_empty";
+    }
+
+  gpgrt_lock_lock (&anon_str_lock);
+  const std::string strData (data);
+  auto it = str_map.find (strData);
+
+  if (it == str_map.end ())
+    {
+      const auto anon = std::string ("gpgol_string_") + std::to_string (cnt);
+      str_map.insert (std::make_pair (strData, anon));
+      it = str_map.find (strData);
+    }
+
+  // As the data is saved in our map we can return
+  // the c_str as it won't be touched as const.
+
+  gpgrt_lock_unlock (&anon_str_lock);
+
+  TRACEPOINT;
+  return it->second.c_str();
+}
diff --git a/src/debug.h b/src/debug.h
index 54a6262..446c587 100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -71,6 +71,7 @@ void log_error_w32 (int w32err, const char *fmt,
 void log_hexdump (const void *buf, size_t buflen, const char *fmt,
                   ...)  __attribute__ ((format (printf,3,4)));
 
+const char *anonstr (const char *data);
 #define log_oom if (opt.enable_debug & DBG_OOM) log_debug
 #define log_data if (opt.enable_debug & DBG_DATA) log_debug
 #define log_memory if (opt.enable_debug & DBG_MEMORY) log_debug

commit 98439ec3551084153e52b25f069d7170d1db5e6f
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Mon Sep 24 11:12:00 2018 +0200

    Use unordered_map in memdbg for performance
    
    * src/memdbg.cpp: Use unordered_map for faster lookups.
    
    --
    This code can be queried very often so a performance
    improvement is nice to have.

diff --git a/src/memdbg.cpp b/src/memdbg.cpp
index cb39e62..02d8172 100644
--- a/src/memdbg.cpp
+++ b/src/memdbg.cpp
@@ -27,13 +27,13 @@
 
 #include <gpg-error.h>
 
-#include <map>
+#include <unordered_map>
 #include <string>
 
-std::map <std::string, int> cppObjs;
-std::map <void *, int> olObjs;
-std::map <void *, std::string> olNames;
-std::map <void *, std::string> allocs;
+std::unordered_map <std::string, int> cppObjs;
+std::unordered_map <void *, int> olObjs;
+std::unordered_map <void *, std::string> olNames;
+std::unordered_map <void *, std::string> allocs;
 
 GPGRT_LOCK_DEFINE (memdbg_log);
 

commit da75bcaa1fc935aa4a770b41e36ce2ce7a218db3
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Mon Sep 24 11:00:11 2018 +0200

    Replace log_mime_data with log_data
    
    * src/mimedataprovider.cpp: Replace log_mime_data with log_data.
    * src/debug.h: Update log macros

diff --git a/src/debug.h b/src/debug.h
index b5b5e49..54a6262 100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -72,10 +72,8 @@ void log_hexdump (const void *buf, size_t buflen, const char *fmt,
                   ...)  __attribute__ ((format (printf,3,4)));
 
 #define log_oom if (opt.enable_debug & DBG_OOM) log_debug
-#define log_oom if (opt.enable_debug & DBG_OOM) log_debug
-#define log_mime_parser if (opt.enable_debug & DBG_DATA) log_debug
 #define log_data if (opt.enable_debug & DBG_DATA) log_debug
-#define log_mime_data if (opt.enable_debug & DBG_DATA) log_debug
+#define log_memory if (opt.enable_debug & DBG_MEMORY) log_debug
 
 #define gpgol_release(X) \
 { \
diff --git a/src/mimedataprovider.cpp b/src/mimedataprovider.cpp
index f629aca..16eb230 100644
--- a/src/mimedataprovider.cpp
+++ b/src/mimedataprovider.cpp
@@ -567,12 +567,12 @@ MimeDataProvider::read(void *buffer, size_t size)
 
       if (!is_binary (buf))
         {
-          log_mime_data ("%s:%s: Data: \n------\n%s\n------",
+          log_data ("%s:%s: Data: \n------\n%s\n------",
                            SRCNAME, __func__, buf.c_str());
         }
       else
         {
-          log_mime_data ("%s:%s: Hex Data: \n------\n%s\n------",
+          log_data ("%s:%s: Hex Data: \n------\n%s\n------",
                            SRCNAME, __func__,
                            string_to_hex (buf).c_str ());
         }
@@ -614,7 +614,7 @@ MimeDataProvider::collect_input_lines(const char *input, size_t insize)
               pos--;
             }
 
-          log_mime_data ("%s:%s: Parsing line=`%.*s'\n",
+          log_data ("%s:%s: Parsing line=`%.*s'\n",
                          SRCNAME, __func__, (int)pos, linebuf);
           /* Check the next state */
           if (rfc822parse_insert (m_mime_ctx->msg,
@@ -653,7 +653,7 @@ MimeDataProvider::collect_input_lines(const char *input, size_t insize)
                 {
                   m_crypto_data.write ("\r\n", 2);
                 }
-              log_mime_data ("Writing raw crypto data: %.*s",
+              log_data ("Writing raw crypto data: %.*s",
                                (int)pos, linebuf);
               m_crypto_data.write (linebuf, pos);
               m_mime_ctx->collect_crypto_data = 2;

commit 296a4d74725cab076ba714564754148fa783da0f
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Mon Sep 24 10:57:19 2018 +0200

    Replace log_oom_extra with log_oom
    
    --

diff --git a/src/application-events.cpp b/src/application-events.cpp
index 1100934..d882e50 100644
--- a/src/application-events.cpp
+++ b/src/application-events.cpp
@@ -101,7 +101,7 @@ EVENT_SINK_INVOKE(ApplicationEvents)
           break;
         }
       default:
-        log_oom_extra ("%s:%s: Unhandled Event: %lx \n",
+        log_oom ("%s:%s: Unhandled Event: %lx \n",
                        SRCNAME, __func__, dispid);
     }
   /* We always return S_OK even on error so that outlook
diff --git a/src/debug.h b/src/debug.h
index 523b540..b5b5e49 100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -72,7 +72,7 @@ void log_hexdump (const void *buf, size_t buflen, const char *fmt,
                   ...)  __attribute__ ((format (printf,3,4)));
 
 #define log_oom if (opt.enable_debug & DBG_OOM) log_debug
-#define log_oom_extra if (opt.enable_debug & DBG_OOM) log_debug
+#define log_oom if (opt.enable_debug & DBG_OOM) log_debug
 #define log_mime_parser if (opt.enable_debug & DBG_DATA) log_debug
 #define log_data if (opt.enable_debug & DBG_DATA) log_debug
 #define log_mime_data if (opt.enable_debug & DBG_DATA) log_debug
diff --git a/src/explorer-events.cpp b/src/explorer-events.cpp
index e9dd776..7ccedfd 100644
--- a/src/explorer-events.cpp
+++ b/src/explorer-events.cpp
@@ -139,7 +139,7 @@ start_watchdog (LPVOID arg)
 
   if ((it->second & SelectSeen))
     {
-      log_oom_extra ("%s:%s: Cancel watchdog as we have seen a select %p",
+      log_oom ("%s:%s: Cancel watchdog as we have seen a select %p",
                      SRCNAME, __func__, explorer);
       it->second = SelectSeen;
     }
@@ -175,14 +175,14 @@ changeSeen (LPDISPATCH explorer)
   if (has_selection)
     {
       it->second = (state & WatchDogActive) + SelectSeen;
-      log_oom_extra ("%s:%s: Seen select for %p",
+      log_oom ("%s:%s: Seen select for %p",
                      SRCNAME, __func__, explorer);
     }
   else
     {
       if ((it->second & WatchDogActive))
         {
-          log_oom_extra ("%s:%s: Seen unselect for %p but watchdog exists.",
+          log_oom ("%s:%s: Seen unselect for %p but watchdog exists.",
                          SRCNAME, __func__, explorer);
         }
       else
@@ -202,14 +202,14 @@ EVENT_SINK_INVOKE(ExplorerEvents)
     {
       case SelectionChange:
         {
-          log_oom_extra ("%s:%s: Selection change in explorer: %p",
+          log_oom ("%s:%s: Selection change in explorer: %p",
                          SRCNAME, __func__, this);
           changeSeen (m_object);
           break;
         }
       case Close:
         {
-          log_oom_extra ("%s:%s: Deleting event handler: %p",
+          log_oom ("%s:%s: Deleting event handler: %p",
                          SRCNAME, __func__, this);
 
           GpgolAddin::get_instance ()->unregisterExplorerSink (this);
@@ -222,7 +222,7 @@ EVENT_SINK_INVOKE(ExplorerEvents)
       default:
         break;
 #if 0
-        log_oom_extra ("%s:%s: Unhandled Event: %lx \n",
+        log_oom ("%s:%s: Unhandled Event: %lx \n",
                        SRCNAME, __func__, dispid);
 #endif
     }
diff --git a/src/folder-events.cpp b/src/folder-events.cpp
index 8c765c1..5becba2 100644
--- a/src/folder-events.cpp
+++ b/src/folder-events.cpp
@@ -49,7 +49,7 @@ EVENT_SINK_INVOKE(FolderEvents)
     {
       case BeforeItemMove:
         {
-          log_oom_extra ("%s:%s: Item Move in folder: %p",
+          log_oom ("%s:%s: Item Move in folder: %p",
                          SRCNAME, __func__, this);
 
           /* Parameters should be
@@ -70,7 +70,7 @@ EVENT_SINK_INVOKE(FolderEvents)
 
           if (!parms->rgvarg[1].pdispVal)
             {
-              log_oom_extra ("%s:%s: Passing delete",
+              log_oom ("%s:%s: Passing delete",
                              SRCNAME, __func__);
               break;
             }
@@ -126,7 +126,7 @@ EVENT_SINK_INVOKE(FolderEvents)
       default:
         break;
 #if 0
-        log_oom_extra ("%s:%s: Unhandled Event: %lx \n",
+        log_oom ("%s:%s: Unhandled Event: %lx \n",
                        SRCNAME, __func__, dispid);
 #endif
     }
diff --git a/src/gpgoladdin.cpp b/src/gpgoladdin.cpp
index 75e9cc8..5f12ab8 100644
--- a/src/gpgoladdin.cpp
+++ b/src/gpgoladdin.cpp
@@ -458,7 +458,7 @@ install_explorer_sinks (LPDISPATCH application)
         }
       else
         {
-          log_oom_extra ("%s:%s: created sink %p for explorer %i",
+          log_oom ("%s:%s: created sink %p for explorer %i",
                          SRCNAME, __func__, sink, i);
           GpgolAddin::get_instance ()->registerExplorerSink (sink);
         }
diff --git a/src/mail.cpp b/src/mail.cpp
index 1f48fd2..f9dfe0c 100644
--- a/src/mail.cpp
+++ b/src/mail.cpp
@@ -155,16 +155,16 @@ Mail::~Mail()
      while parsing. */
   gpgrt_lock_lock (&dtor_lock);
   memdbg_dtor ("Mail");
-  log_oom_extra ("%s:%s: dtor: Mail: %p item: %p",
+  log_oom ("%s:%s: dtor: Mail: %p item: %p",
                  SRCNAME, __func__, this, m_mailitem);
   std::map<LPDISPATCH, Mail *>::iterator it;
 
-  log_oom_extra ("%s:%s: Detaching event sink",
+  log_oom ("%s:%s: Detaching event sink",
                  SRCNAME, __func__);
   detach_MailItemEvents_sink (m_event_sink);
   gpgol_release(m_event_sink);
 
-  log_oom_extra ("%s:%s: Erasing mail",
+  log_oom ("%s:%s: Erasing mail",
                  SRCNAME, __func__);
   gpgrt_lock_lock (&mail_map_lock);
   it = s_mail_map.find(m_mailitem);
@@ -185,29 +185,29 @@ Mail::~Mail()
       gpgrt_lock_unlock (&uid_map_lock);
     }
 
-  log_oom_extra ("%s:%s: releasing mailitem",
+  log_oom ("%s:%s: releasing mailitem",
                  SRCNAME, __func__);
   gpgol_release(m_mailitem);
   xfree (m_cached_html_body);
   xfree (m_cached_plain_body);
   if (!m_uuid.empty())
     {
-      log_oom_extra ("%s:%s: destroyed: %p uuid: %s",
+      log_oom ("%s:%s: destroyed: %p uuid: %s",
                      SRCNAME, __func__, this, m_uuid.c_str());
     }
   else
     {
-      log_oom_extra ("%s:%s: non crypto (or sent) mail: %p destroyed",
+      log_oom ("%s:%s: non crypto (or sent) mail: %p destroyed",
                      SRCNAME, __func__, this);
     }
-  log_oom_extra ("%s:%s: nulling shared pointer",
+  log_oom ("%s:%s: nulling shared pointer",
                  SRCNAME, __func__);
   m_parser = nullptr;
   m_crypter = nullptr;
 
   releaseCurrentItem();
   gpgrt_lock_unlock (&dtor_lock);
-  log_oom_extra ("%s:%s: returning",
+  log_oom ("%s:%s: returning",
                  SRCNAME, __func__);
 }
 
@@ -277,7 +277,7 @@ Mail::preProcessMessage_m ()
                  SRCNAME, __func__);
       return 0;
     }
-  log_oom_extra ("%s:%s: GetBaseMessage OK for %p.",
+  log_oom ("%s:%s: GetBaseMessage OK for %p.",
                  SRCNAME, __func__, m_mailitem);
   /* Change the message class here. It is important that
      we change the message class in the before read event
@@ -1333,7 +1333,7 @@ void
 Mail::parsing_done()
 {
   TRACEPOINT;
-  log_oom_extra ("Mail %p Parsing done for parser num %i: %p",
+  log_oom ("Mail %p Parsing done for parser num %i: %p",
                  this, parsed_count++, m_parser.get());
   if (!m_parser)
     {
@@ -1919,13 +1919,13 @@ Mail::close (Mail *mail)
   dispparams.cArgs = 1;
   dispparams.cNamedArgs = 0;
 
-  log_oom_extra ("%s:%s: Invoking close for: %p",
+  log_oom ("%s:%s: Invoking close for: %p",
                  SRCNAME, __func__, mail->item());
   mail->setCloseTriggered (true);
   int rc = invoke_oom_method_with_parms (mail->item(), "Close",
                                        NULL, &dispparams);
 
-  log_oom_extra ("%s:%s: Returned from close",
+  log_oom ("%s:%s: Returned from close",
                  SRCNAME, __func__);
   return rc;
 }
@@ -3555,7 +3555,7 @@ Mail::releaseCurrentItem()
     {
       return;
     }
-  log_oom_extra ("%s:%s: releasing CurrentItem ref %p",
+  log_oom ("%s:%s: releasing CurrentItem ref %p",
                  SRCNAME, __func__, m_currentItemRef);
   LPDISPATCH tmp = m_currentItemRef;
   m_currentItemRef = nullptr;
diff --git a/src/mailitem-events.cpp b/src/mailitem-events.cpp
index 03296f0..86af6a1 100644
--- a/src/mailitem-events.cpp
+++ b/src/mailitem-events.cpp
@@ -142,7 +142,7 @@ EVENT_SINK_INVOKE(MailItemEvents)
     {
       case Open:
         {
-          log_oom_extra ("%s:%s: Open : %p",
+          log_oom ("%s:%s: Open : %p",
                          SRCNAME, __func__, m_mail);
           int draft_flags = 0;
           if (!opt.encrypt_default && !opt.sign_default)
@@ -170,7 +170,7 @@ EVENT_SINK_INVOKE(MailItemEvents)
         }
       case BeforeRead:
         {
-          log_oom_extra ("%s:%s: BeforeRead : %p",
+          log_oom ("%s:%s: BeforeRead : %p",
                          SRCNAME, __func__, m_mail);
           if (m_mail->preProcessMessage_m ())
             {
@@ -181,7 +181,7 @@ EVENT_SINK_INVOKE(MailItemEvents)
         }
       case Read:
         {
-          log_oom_extra ("%s:%s: Read : %p",
+          log_oom ("%s:%s: Read : %p",
                          SRCNAME, __func__, m_mail);
           if (!m_mail->isCryptoMail ())
             {
@@ -323,7 +323,7 @@ EVENT_SINK_INVOKE(MailItemEvents)
         }
       case CustomPropertyChange:
         {
-          log_oom_extra ("%s:%s: CustomPropertyChange : %p",
+          log_oom ("%s:%s: CustomPropertyChange : %p",
                          SRCNAME, __func__, m_mail);
           /* TODO */
           break;
@@ -345,7 +345,7 @@ EVENT_SINK_INVOKE(MailItemEvents)
              If this encryption is successful and we pass the send
              as then the encrypted data is sent.
            */
-          log_oom_extra ("%s:%s: Send : %p",
+          log_oom ("%s:%s: Send : %p",
                          SRCNAME, __func__, m_mail);
           if (!m_mail->needs_crypto_m () && m_mail->cryptState () == Mail::NoCryptMail)
             {
@@ -553,7 +553,7 @@ EVENT_SINK_INVOKE(MailItemEvents)
         }
       case Write:
         {
-          log_oom_extra ("%s:%s: Write : %p",
+          log_oom ("%s:%s: Write : %p",
                          SRCNAME, __func__, m_mail);
           /* This is a bit strange. We sometimes get multiple write events
              without a read in between. When we access the message in
@@ -671,7 +671,7 @@ EVENT_SINK_INVOKE(MailItemEvents)
         }
       case AfterWrite:
         {
-          log_oom_extra ("%s:%s: AfterWrite : %p",
+          log_oom ("%s:%s: AfterWrite : %p",
                          SRCNAME, __func__, m_mail);
           if (m_mail->cryptState () == Mail::NeedsFirstAfterWrite)
             {
@@ -695,7 +695,7 @@ EVENT_SINK_INVOKE(MailItemEvents)
         }
       case Close:
         {
-          log_oom_extra ("%s:%s: Close : %p",
+          log_oom ("%s:%s: Close : %p",
                          SRCNAME, __func__, m_mail);
           if (m_mail->isCryptoMail ())
             {
@@ -721,7 +721,7 @@ EVENT_SINK_INVOKE(MailItemEvents)
                   return S_OK;
                 }
               *(parms->rgvarg[0].pboolVal) = VARIANT_TRUE;
-              log_oom_extra ("%s:%s: Canceling close event.",
+              log_oom ("%s:%s: Canceling close event.",
                              SRCNAME, __func__);
               if (Mail::close(m_mail))
                 {
@@ -733,12 +733,12 @@ EVENT_SINK_INVOKE(MailItemEvents)
         }
       case Unload:
         {
-          log_oom_extra ("%s:%s: Unload : %p",
+          log_oom ("%s:%s: Unload : %p",
                          SRCNAME, __func__, m_mail);
           log_debug ("%s:%s: Removing Mail for message: %p.",
                      SRCNAME, __func__, m_object);
           delete m_mail;
-          log_oom_extra ("%s:%s: deletion done",
+          log_oom ("%s:%s: deletion done",
                          SRCNAME, __func__);
           memdbg_dump ();
           return S_OK;
@@ -751,7 +751,7 @@ EVENT_SINK_INVOKE(MailItemEvents)
         }
       case Forward:
         {
-          log_oom_extra ("%s:%s: %s : %p",
+          log_oom ("%s:%s: %s : %p",
                          SRCNAME, __func__, is_reply ? "reply" : "forward", m_mail);
           int draft_flags = 0;
           if (opt.encrypt_default)
@@ -867,7 +867,7 @@ EVENT_SINK_INVOKE(MailItemEvents)
               Mail::clearLastMail ();
             }
 
-          log_oom_extra ("%s:%s: Reply Forward ReplyAll: %p",
+          log_oom ("%s:%s: Reply Forward ReplyAll: %p",
                          SRCNAME, __func__, m_mail);
           if (!opt.reply_crypt)
             {
@@ -900,7 +900,7 @@ EVENT_SINK_INVOKE(MailItemEvents)
         }
       case AttachmentRemove:
         {
-          log_oom_extra ("%s:%s: AttachmentRemove: %p",
+          log_oom ("%s:%s: AttachmentRemove: %p",
                          SRCNAME, __func__, m_mail);
           if (!m_mail->isCryptoMail () || attachRemoveWarnShown ||
               m_mail->attachmentRemoveWarningDisabled ())
@@ -917,7 +917,7 @@ EVENT_SINK_INVOKE(MailItemEvents)
         }
 
       default:
-        log_oom_extra ("%s:%s: Message:%p Unhandled Event: %lx \n",
+        log_oom ("%s:%s: Message:%p Unhandled Event: %lx \n",
                        SRCNAME, __func__, m_object, dispid);
     }
   return S_OK;
diff --git a/src/memdbg.h b/src/memdbg.h
index aa4939d..ffbdae9 100644
--- a/src/memdbg.h
+++ b/src/memdbg.h
@@ -33,7 +33,7 @@ extern "C" {
 { \
   if (X) \
     { \
-      log_oom_extra ("%s:%s:%i AddRef on %p", \
+      log_oom ("%s:%s:%i AddRef on %p", \
                      SRCNAME, __func__, __LINE__, X); \
       _memdbg_addRef (X, __func__); \
     } \
diff --git a/src/oomhelp.cpp b/src/oomhelp.cpp
index 2c162ab..143f13f 100644
--- a/src/oomhelp.cpp
+++ b/src/oomhelp.cpp
@@ -1595,7 +1595,7 @@ get_oom_base_message_from_mapi (LPDISPATCH mapi_message)
   /* The call to GetBaseMessage is pretty much a jump
      in the dark. So it would not be surprising to get
      crashes here in the future. */
-  log_oom_extra("%s:%s: About to call GetBaseMessage.",
+  log_oom("%s:%s: About to call GetBaseMessage.",
                 SRCNAME, __func__);
   hr = secureMessage->GetBaseMessage (&message);
   memdbg_addRef (message);
diff --git a/src/windowmessages.cpp b/src/windowmessages.cpp
index d239377..c6e585c 100644
--- a/src/windowmessages.cpp
+++ b/src/windowmessages.cpp
@@ -536,7 +536,7 @@ void
 blockInv()
 {
   invalidation_blocked++;
-  log_oom_extra ("%s:%s: Invalidation block count %i",
+  log_oom ("%s:%s: Invalidation block count %i",
                  SRCNAME, __func__, invalidation_blocked);
 }
 
@@ -544,7 +544,7 @@ void
 unblockInv()
 {
   invalidation_blocked--;
-  log_oom_extra ("%s:%s: Invalidation block count %i",
+  log_oom ("%s:%s: Invalidation block count %i",
                  SRCNAME, __func__, invalidation_blocked);
 
   if (invalidation_blocked < 0)

commit 177b72b8c33a2459e20695e01492573211c150f8
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Mon Sep 24 10:56:40 2018 +0200

    Add "Supertrace" macros
    
    * src/debug.h (TSTART, TRETURN, DBG_SUPERTRACE): New macros
    for a new super verbose tracing.

diff --git a/src/debug.h b/src/debug.h
index 36fafdc..523b540 100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -55,6 +55,7 @@ extern "C" {
 #define DBG_DATA           (DBG_MIME_PARSER | DBG_MIME_DATA)
 #define DBG_OOM_VAL        (1<<9) // 512 Unified as DBG_OOM
 #define DBG_OOM_EXTRA      (1<<10)// 1024 Unified as DBG_OOM
+#define DBG_SUPERTRACE     (1<<11)// 2048 Very verbose tracing.
 #define DBG_OOM            (DBG_OOM_VAL | DBG_OOM_EXTRA)
 
 #define debug_oom        ((opt.enable_debug & DBG_OOM) || \
@@ -95,6 +96,13 @@ const char *log_srcname (const char *s);
 
 #define TRACEPOINT log_debug ("%s:%s:%d: tracepoint\n", \
                               SRCNAME, __func__, __LINE__);
+#define TSTART if (opt.enable_debug & DBG_SUPERTRACE) \
+                    log_debug ("%s:%s: enter\n", SRCNAME, __func__);
+#define TRETURN(X) if (opt.enable_debug & DBG_SUPERTRACE) \
+                        log_debug ("%s:%s:%d: return\n", SRCNAME, __func__, \
+                                   __LINE__); \
+                   return X
+
 
 const char *get_log_file (void);
 void set_log_file (const char *name);

commit 5156d7b1da1fd9463e9442f5e913b6b24c0a7b69
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Mon Sep 24 10:02:13 2018 +0200

    Log if logging fails
    
    * src/debug.cpp (lock_log): Do not wait infinite for
    log lock.
    (do_log): Log to debug output if obtaining the log lock failed.
    
    --
    I do not see how this can fail. But still an infinite wait
    should be avoided and the failure handled at least with a
    short note.

diff --git a/src/debug.cpp b/src/debug.cpp
index 7f15550..b268e86 100644
--- a/src/debug.cpp
+++ b/src/debug.cpp
@@ -31,7 +31,7 @@ static FILE *logfp;
 static int
 lock_log (void)
 {
-  int code = WaitForSingleObject (log_mutex, INFINITE);
+  int code = WaitForSingleObject (log_mutex, 10000);
   return code != WAIT_OBJECT_0;
 }
 
@@ -86,7 +86,10 @@ do_log (const char *fmt, va_list a, int w32err, int err,
     return;
 
   if (lock_log ())
-    return;
+    {
+      OutputDebugStringA ("GpgOL: Failed to log.");
+      return;
+    }
 #endif
 
   if (!strcmp (logfile, "stdout"))

-----------------------------------------------------------------------

Summary of changes:
 src/Makefile.am            |   1 -
 src/application-events.cpp |   2 +-
 src/debug.cpp              |  53 +++++++++++++++-
 src/debug.h                |  13 +++-
 src/exechelp.c             | 150 ---------------------------------------------
 src/exechelp.h             |  51 ---------------
 src/explorer-events.cpp    |  12 ++--
 src/folder-events.cpp      |   6 +-
 src/gpgoladdin.cpp         |   2 +-
 src/mail.cpp               |  26 ++++----
 src/mailitem-events.cpp    |  30 ++++-----
 src/memdbg.cpp             |  10 +--
 src/memdbg.h               |   2 +-
 src/mimedataprovider.cpp   |   8 +--
 src/oomhelp.cpp            |   2 +-
 src/windowmessages.cpp     |   4 +-
 16 files changed, 113 insertions(+), 259 deletions(-)
 delete mode 100644 src/exechelp.c
 delete mode 100644 src/exechelp.h


hooks/post-receive
-- 
GnuPG extension for MS Outlook
http://git.gnupg.org




More information about the Gnupg-commits mailing list