2009-06-18 Marcus Brinkmann <marcus@g10code.de>

* gpgme.h.in (GPGME_CONF_PATHNAME): Remove obsolete macro.

	* w32-io.c (_gpgme_io_pipe): Allocate reader/writer thread right
	away.
	(_gpgme_io_read, _gpgme_io_write, _gpgme_io_select)
	(_gpgme_io_dup): Never allocate threads here.
	(find_writer, find_reader): Check return value of thread creation
	function.
This commit is contained in:
Marcus Brinkmann 2009-06-18 13:41:48 +00:00
parent 3ab899f41c
commit 0d77c1a3aa
4 changed files with 56 additions and 23 deletions

14
TODO
View File

@ -8,24 +8,20 @@ Hey Emacs, this is -*- org -*- mode!
we block reading the next line with assuan. we block reading the next line with assuan.
* Before release: * Before release:
** Figure out if _gpgme_io_pipe should pre-create reader/writer and if we
then can use !start_it in most invocations. Note that gpgme_io_dup
probably should always use !start_it, because currently it will
always create reader/writer if they don't exist(!?).
** Some gpg tests fail with gpg 1.3.4-cvs (gpg/t-keylist-sig) ** Some gpg tests fail with gpg 1.3.4-cvs (gpg/t-keylist-sig)
The test is currently disabled there and in gpg/t-import. The test is currently disabled there and in gpg/t-import.
** When gpg supports it, write binary subpackets directly, ** When gpg supports it, write binary subpackets directly,
and parse SUBPACKET status lines. and parse SUBPACKET status lines.
** A few months after 1.1.7:
Remove GPGME_CONF_PATHNAME macro.
* ABI's to break: * ABI's to break:
** Implementation: Remove support for old style error codes in
conversion.c::_gpgme_map_gnupg_error.
** gpgme_edit_cb_t: Add "processed" return argument ** gpgme_edit_cb_t: Add "processed" return argument
(see edit.c::command_handler). (see edit.c::command_handler).
** I/O and User Data could be made extensible. But this can be done ** I/O and User Data could be made extensible. But this can be done
without breaking the ABI hopefully. without breaking the ABI hopefully.
** All enums that should be enums need to have a maximum value to ensure ** All enums should be replaced by ints and simple macros for
a certain minimum width for extensibility. maximum compatibility.
** Compatibility interfaces that can be removed in future versions: ** Compatibility interfaces that can be removed in future versions:
*** gpgme_data_new_from_filepart *** gpgme_data_new_from_filepart
*** gpgme_data_new_from_file *** gpgme_data_new_from_file
@ -109,7 +105,7 @@ Hey Emacs, this is -*- org -*- mode!
the fds unregistered immediately - i think so?) the fds unregistered immediately - i think so?)
Note that we need support in gpgsm to set include-certs to default Note that we need support in gpgsm to set include-certs to default
as RESET does not reset it. as RESET does not reset it.
** Optimize the case where a data object has 0an underlying fd we can pass ** Optimize the case where a data object has an underlying fd we can pass
directly to the engine. This will be automatic with socket I/O and directly to the engine. This will be automatic with socket I/O and
descriptor passing. descriptor passing.
** Move code common to all engines up from gpg to engine. ** Move code common to all engines up from gpg to engine.

View File

@ -1,5 +1,14 @@
2009-06-18 Marcus Brinkmann <marcus@g10code.de> 2009-06-18 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h.in (GPGME_CONF_PATHNAME): Remove obsolete macro.
* w32-io.c (_gpgme_io_pipe): Allocate reader/writer thread right
away.
(_gpgme_io_read, _gpgme_io_write, _gpgme_io_select)
(_gpgme_io_dup): Never allocate threads here.
(find_writer, find_reader): Check return value of thread creation
function.
* context.h (CTX_OP_DATA_MAGIC): New macro. * context.h (CTX_OP_DATA_MAGIC): New macro.
(struct ctx_op_data): New member MAGIC. (struct ctx_op_data): New member MAGIC.
* op-support.c (_gpgme_op_data_lookup): Initialize magic. * op-support.c (_gpgme_op_data_lookup): Initialize magic.

View File

@ -1793,9 +1793,6 @@ typedef enum
GPGME_CONF_ALIAS_LIST = 37 GPGME_CONF_ALIAS_LIST = 37
} }
gpgme_conf_type_t; gpgme_conf_type_t;
/* Macro for backward compatibility (even though it was undocumented
and marked as experimental in 1.1.6 - will be removed after 1.1.7): */
#define GPGME_CONF_PATHNAME GPGME_CONF_FILENAME
/* This represents a single argument for a configuration option. /* This represents a single argument for a configuration option.

View File

@ -389,9 +389,12 @@ find_reader (int fd, int start_it)
if (i != reader_table_size) if (i != reader_table_size)
{ {
rd = create_reader (fd_to_handle (fd)); rd = create_reader (fd_to_handle (fd));
reader_table[i].fd = fd; if (rd)
reader_table[i].context = rd; {
reader_table[i].used = 1; reader_table[i].fd = fd;
reader_table[i].context = rd;
reader_table[i].used = 1;
}
} }
UNLOCK (reader_table_lock); UNLOCK (reader_table_lock);
@ -692,9 +695,12 @@ find_writer (int fd, int start_it)
if (i != writer_table_size) if (i != writer_table_size)
{ {
wt = create_writer (fd_to_handle (fd)); wt = create_writer (fd_to_handle (fd));
writer_table[i].fd = fd; if (wt)
writer_table[i].context = wt; {
writer_table[i].used = 1; writer_table[i].fd = fd;
writer_table[i].context = wt;
writer_table[i].used = 1;
}
} }
UNLOCK (writer_table_lock); UNLOCK (writer_table_lock);
@ -733,7 +739,7 @@ _gpgme_io_write (int fd, const void *buffer, size_t count)
if (count == 0) if (count == 0)
return TRACE_SYSRES (0); return TRACE_SYSRES (0);
ctx = find_writer (fd, 1); ctx = find_writer (fd, 0);
if (!ctx) if (!ctx)
return TRACE_SYSRES (-1); return TRACE_SYSRES (-1);
@ -826,6 +832,7 @@ _gpgme_io_pipe (int filedes[2], int inherit_idx)
/* Make one end inheritable. */ /* Make one end inheritable. */
if (inherit_idx == 0) if (inherit_idx == 0)
{ {
struct writer_context_s *ctx;
HANDLE hd; HANDLE hd;
if (!DuplicateHandle (GetCurrentProcess(), rh, if (!DuplicateHandle (GetCurrentProcess(), rh,
GetCurrentProcess(), &hd, 0, GetCurrentProcess(), &hd, 0,
@ -841,6 +848,18 @@ _gpgme_io_pipe (int filedes[2], int inherit_idx)
} }
CloseHandle (rh); CloseHandle (rh);
rh = hd; rh = hd;
ctx = find_writer (handle_to_fd (wh), 0);
assert (ctx == NULL);
ctx = find_writer (handle_to_fd (wh), 1);
if (!ctx)
{
CloseHandle (rh);
CloseHandle (wh);
/* FIXME: Should translate the error code. */
errno = EIO;
return TRACE_SYSRES (-1);
}
} }
else if (inherit_idx == 1) else if (inherit_idx == 1)
{ {
@ -859,6 +878,18 @@ _gpgme_io_pipe (int filedes[2], int inherit_idx)
} }
CloseHandle (wh); CloseHandle (wh);
wh = hd; wh = hd;
ctx = find_reader (handle_to_fd (rh), 0);
assert (ctx == NULL);
ctx = find_reader (handle_to_fd (rh), 1);
if (!ctx)
{
CloseHandle (rh);
CloseHandle (wh);
/* FIXME: Should translate the error code. */
errno = EIO;
return TRACE_SYSRES (-1);
}
} }
filedes[0] = handle_to_fd (rh); filedes[0] = handle_to_fd (rh);
@ -1248,7 +1279,7 @@ _gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock)
{ {
if (fds[i].for_read) if (fds[i].for_read)
{ {
struct reader_context_s *ctx = find_reader (fds[i].fd,1); struct reader_context_s *ctx = find_reader (fds[i].fd,0);
if (!ctx) if (!ctx)
TRACE_LOG1 ("error: no reader for FD 0x%x (ignored)", TRACE_LOG1 ("error: no reader for FD 0x%x (ignored)",
@ -1271,7 +1302,7 @@ _gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock)
} }
else if (fds[i].for_write) else if (fds[i].for_write)
{ {
struct writer_context_s *ctx = find_writer (fds[i].fd,1); struct writer_context_s *ctx = find_writer (fds[i].fd,0);
if (!ctx) if (!ctx)
TRACE_LOG1 ("error: no writer for FD 0x%x (ignored)", TRACE_LOG1 ("error: no writer for FD 0x%x (ignored)",
@ -1417,7 +1448,7 @@ _gpgme_io_dup (int fd)
return TRACE_SYSRES (-1); return TRACE_SYSRES (-1);
} }
rd_ctx = find_reader (fd, 1); rd_ctx = find_reader (fd, 0);
if (rd_ctx) if (rd_ctx)
{ {
/* No need for locking, as the only races are against the reader /* No need for locking, as the only races are against the reader
@ -1436,7 +1467,7 @@ _gpgme_io_dup (int fd)
UNLOCK (reader_table_lock); UNLOCK (reader_table_lock);
} }
wt_ctx = find_writer (fd, 1); wt_ctx = find_writer (fd, 0);
if (wt_ctx) if (wt_ctx)
{ {
/* No need for locking, as the only races are against the writer /* No need for locking, as the only races are against the writer