[svn] w32pth - r38 - trunk
svn author wk
cvs at cvs.gnupg.org
Fri Jul 23 18:17:38 CEST 2010
Author: wk
Date: 2010-07-23 18:17:38 +0200 (Fri, 23 Jul 2010)
New Revision: 38
Modified:
trunk/ChangeLog
trunk/NEWS
trunk/pth.h
trunk/w32-pth.c
Log:
Add pth_enter and pth_leave functions.
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-04-19 09:26:56 UTC (rev 37)
+++ trunk/ChangeLog 2010-07-23 16:17:38 UTC (rev 38)
@@ -1,3 +1,8 @@
+2010-07-21 Werner Koch <wk at g10code.com>
+
+ * w32-pth.c (enter_leave_api_sentinel): New.
+ (pth_enter, pth_leave): New.
+
2010-04-19 Werner Koch <wk at g10code.com>
* w32-pth.c (is_socket_2): New.
Modified: trunk/NEWS
===================================================================
--- trunk/NEWS 2010-04-19 09:26:56 UTC (rev 37)
+++ trunk/NEWS 2010-07-23 16:17:38 UTC (rev 38)
@@ -1,9 +1,11 @@
-Noteworthy changes in version 2.0.3
+Noteworthy changes in version 2.0.3
------------------------------------------------
* Support WindowsCE.
+ * New functions pth_enter and pth_leave.
+
Noteworthy changes in version 2.0.2 (2008-10-17)
------------------------------------------------
Modified: trunk/pth.h
===================================================================
--- trunk/pth.h 2010-04-19 09:26:56 UTC (rev 37)
+++ trunk/pth.h 2010-07-23 16:17:38 UTC (rev 38)
@@ -277,7 +277,10 @@
int pth_yield (pth_t tid);
+void pth_enter (void);
+void pth_leave (void);
+
/* Special W32 function to cope with the problem that pth_self returns
just a pseudo handle which is not very useful for debugging. */
unsigned long pth_thread_id (void);
Modified: trunk/w32-pth.c
===================================================================
--- trunk/w32-pth.c 2010-04-19 09:26:56 UTC (rev 37)
+++ trunk/w32-pth.c 2010-07-23 16:17:38 UTC (rev 38)
@@ -76,6 +76,9 @@
/* Mutex to make sure only one thread is running. */
static CRITICAL_SECTION pth_shd;
+/* A sentinel to catch bogus use of pth_enter/pth_leave. */
+static int enter_leave_api_sentinel;
+
/* Counter to track the number of PTH threads. */
static int thread_counter;
@@ -762,7 +765,7 @@
if (!dbgfp)
dbgfp = stderr;
if (debug_level)
- _pth_debug (DEBUG_ERROR, "pth_init called\n");
+ _pth_debug (DEBUG_ERROR, "pth_init called (level=%d)\n", debug_level);
if (WSAStartup (0x202, &wsadat))
return FALSE;
@@ -832,6 +835,33 @@
}
+void
+pth_enter (void)
+{
+ implicit_init ();
+ if (enter_leave_api_sentinel)
+ {
+ fprintf (stderr, "pth_enter called while already in pth\n");
+ abort ();
+ }
+ enter_leave_api_sentinel++;
+ enter_pth (__FUNCTION__);
+}
+
+
+void
+pth_leave (void)
+{
+ leave_pth (__FUNCTION__);
+ if (enter_leave_api_sentinel != 1)
+ {
+ fprintf (stderr, "pth_leave was called while not in pth\n");
+ abort ();
+ }
+ enter_leave_api_sentinel--;
+}
+
+
long
pth_ctrl (unsigned long query, ...)
{
@@ -945,6 +975,8 @@
HANDLE hd;
int use_readfile = 0;
+ TRACE_BEG (DEBUG_INFO, "do_pth_read", fd);
+
/* We have to check for internal pipes first, as socket operations
can block on these. */
hd = _pth_get_reader_ev (fd);
@@ -970,7 +1002,12 @@
DWORD nread = 0;
do
- n = ReadFile ((HANDLE)fd, buffer, size, &nread, NULL);
+ {
+
+ TRACE_LOG2 (" ReadFile on %p size=%d", (HANDLE)fd, (int)size);
+ n = ReadFile ((HANDLE)fd, buffer, size, &nread, NULL);
+ TRACE_LOG2 (" n=%d nread=%d", n, (int)nread);
+ }
while (!n && pipe_is_not_connected ());
if (!n)
{
@@ -995,6 +1032,7 @@
}
}
+ TRACE_SYSRES (n);
return n;
}
More information about the Gnupg-commits
mailing list