2003-06-06 Marcus Brinkmann <marcus@g10code.de>
* posix-io.c (_gpgme_io_read): Save errno across debug calls. (_gpgme_io_write): Likewise. (_gpgme_io_pipe): Likewise. (_gpgme_io_select): Likewise.
This commit is contained in:
parent
e03686e013
commit
ef2ffa5165
1
TODO
1
TODO
@ -2,7 +2,6 @@ Hey Emacs, this is -*- outline -*- mode!
|
|||||||
|
|
||||||
* Before release:
|
* Before release:
|
||||||
** Change gpgme_invalid_user_id_t to gpgme_invalid_key_t.
|
** Change gpgme_invalid_user_id_t to gpgme_invalid_key_t.
|
||||||
** Make sure POSIX I/O functions set errno properly
|
|
||||||
** gpgme-config must include info about libgpg-error.
|
** gpgme-config must include info about libgpg-error.
|
||||||
|
|
||||||
* ABI's to break:
|
* ABI's to break:
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
2003-06-06 Marcus Brinkmann <marcus@g10code.de>
|
2003-06-06 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* posix-io.c (_gpgme_io_read): Save errno across debug calls.
|
||||||
|
(_gpgme_io_write): Likewise.
|
||||||
|
(_gpgme_io_pipe): Likewise.
|
||||||
|
(_gpgme_io_select): Likewise.
|
||||||
|
|
||||||
* rungpg.c (struct engine_gpg): Remove arg_error.
|
* rungpg.c (struct engine_gpg): Remove arg_error.
|
||||||
(add_arg): Don't set arg_error.
|
(add_arg): Don't set arg_error.
|
||||||
(add_data): Likewise.
|
(add_data): Likewise.
|
||||||
|
@ -49,16 +49,19 @@ int
|
|||||||
_gpgme_io_read (int fd, void *buffer, size_t count)
|
_gpgme_io_read (int fd, void *buffer, size_t count)
|
||||||
{
|
{
|
||||||
int nread;
|
int nread;
|
||||||
|
int saved_errno;
|
||||||
|
|
||||||
DEBUG2 ("fd %d: about to read %d bytes\n", fd, (int) count);
|
DEBUG2 ("fd %d: about to read %d bytes\n", fd, (int) count);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
nread = _gpgme_ath_read (fd, buffer, count);
|
nread = _gpgme_ath_read (fd, buffer, count);
|
||||||
}
|
}
|
||||||
while (nread == -1 && errno == EINTR );
|
while (nread == -1 && errno == EINTR);
|
||||||
|
saved_errno = errno;
|
||||||
DEBUG2 ("fd %d: got %d bytes\n", fd, nread);
|
DEBUG2 ("fd %d: got %d bytes\n", fd, nread);
|
||||||
if (nread > 0)
|
if (nread > 0)
|
||||||
_gpgme_debug (2, "fd %d: got `%.*s'\n", fd, nread, buffer);
|
_gpgme_debug (2, "fd %d: got `%.*s'\n", fd, nread, buffer);
|
||||||
|
errno = saved_errno;
|
||||||
return nread;
|
return nread;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,6 +69,7 @@ _gpgme_io_read (int fd, void *buffer, size_t count)
|
|||||||
int
|
int
|
||||||
_gpgme_io_write (int fd, const void *buffer, size_t count)
|
_gpgme_io_write (int fd, const void *buffer, size_t count)
|
||||||
{
|
{
|
||||||
|
int saved_errno;
|
||||||
int nwritten;
|
int nwritten;
|
||||||
|
|
||||||
DEBUG2 ("fd %d: about to write %d bytes\n", fd, (int) count);
|
DEBUG2 ("fd %d: about to write %d bytes\n", fd, (int) count);
|
||||||
@ -75,13 +79,17 @@ _gpgme_io_write (int fd, const void *buffer, size_t count)
|
|||||||
nwritten = _gpgme_ath_write (fd, buffer, count);
|
nwritten = _gpgme_ath_write (fd, buffer, count);
|
||||||
}
|
}
|
||||||
while (nwritten == -1 && errno == EINTR);
|
while (nwritten == -1 && errno == EINTR);
|
||||||
|
saved_errno = errno;
|
||||||
DEBUG2 ("fd %d: wrote %d bytes\n", fd, (int) nwritten);
|
DEBUG2 ("fd %d: wrote %d bytes\n", fd, (int) nwritten);
|
||||||
|
errno = saved_errno;
|
||||||
return nwritten;
|
return nwritten;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
_gpgme_io_pipe (int filedes[2], int inherit_idx)
|
_gpgme_io_pipe (int filedes[2], int inherit_idx)
|
||||||
{
|
{
|
||||||
|
int saved_errno;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = pipe (filedes);
|
err = pipe (filedes);
|
||||||
@ -89,11 +97,13 @@ _gpgme_io_pipe (int filedes[2], int inherit_idx)
|
|||||||
return err;
|
return err;
|
||||||
/* FIXME: Should get the old flags first. */
|
/* FIXME: Should get the old flags first. */
|
||||||
err = fcntl (filedes[1 - inherit_idx], F_SETFD, FD_CLOEXEC);
|
err = fcntl (filedes[1 - inherit_idx], F_SETFD, FD_CLOEXEC);
|
||||||
|
saved_errno = errno;
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
{
|
{
|
||||||
close (filedes[0]);
|
close (filedes[0]);
|
||||||
close (filedes[1]);
|
close (filedes[1]);
|
||||||
}
|
}
|
||||||
|
errno = saved_errno;
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +167,6 @@ _gpgme_io_spawn (const char *path, char **argv,
|
|||||||
pid_t pid;
|
pid_t pid;
|
||||||
int i;
|
int i;
|
||||||
int status, signo;
|
int status, signo;
|
||||||
|
|
||||||
LOCK (fixed_signals_lock);
|
LOCK (fixed_signals_lock);
|
||||||
if (!fixed_signals)
|
if (!fixed_signals)
|
||||||
{
|
{
|
||||||
@ -356,7 +365,9 @@ _gpgme_io_select (struct io_select_fd_s *fds, size_t nfds, int nonblock)
|
|||||||
while (count < 0 && errno == EINTR);
|
while (count < 0 && errno == EINTR);
|
||||||
if (count < 0)
|
if (count < 0)
|
||||||
{
|
{
|
||||||
|
int saved_errno = errno;
|
||||||
DEBUG1 ("_gpgme_io_select failed: %s\n", strerror (errno));
|
DEBUG1 ("_gpgme_io_select failed: %s\n", strerror (errno));
|
||||||
|
errno = saved_errno;
|
||||||
return -1; /* error */
|
return -1; /* error */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user