Possible fix for NT and segv fix.

This commit is contained in:
Werner Koch 2001-02-01 09:25:56 +00:00
parent 1648829c39
commit 6bbbad60f2
3 changed files with 25 additions and 11 deletions

View File

@ -1,6 +1,14 @@
2001-02-01 Werner Koch <wk@gnupg.org>
* w32-io.c (set_synchronize): Add EVENT_MODIFY_STATE. Add Debug
code to all Set/ResetEvent().
* rungpg.c (read_status): Check for end of stream only if we have
an r. By Timo.
2001-01-31 Werner Koch <wk@gnupg.org> 2001-01-31 Werner Koch <wk@gnupg.org>
* wait.c (_gpgme_wait_on_condition): Remove all exit code processing. * wait.c (_gpgme_wait_on_condition): Removed all exit code processing.
(propagate_term_results,clear_active_fds): Removed. (propagate_term_results,clear_active_fds): Removed.
(count_active_fds): Renamed to .. (count_active_fds): Renamed to ..
(count_active_and_thawed_fds): .. this and count only thawed fds. (count_active_and_thawed_fds): .. this and count only thawed fds.

View File

@ -1016,10 +1016,11 @@ read_status ( GpgObject gpg )
gpg->status.fnc ( gpg->status.fnc_value, gpg->status.fnc ( gpg->status.fnc_value,
r->code, rest); r->code, rest);
} }
}
if ( r->code == STATUS_END_STREAM ) { if ( r->code == STATUS_END_STREAM ) {
if ( gpg->cmd.used ) if ( gpg->cmd.used )
_gpgme_freeze_fd ( gpg->cmd.fd ); _gpgme_freeze_fd ( gpg->cmd.fd );
}
} }
} }
/* To reuse the buffer for the next line we have to /* To reuse the buffer for the next line we have to

View File

@ -87,7 +87,7 @@ set_synchronize (HANDLE h)
* way to do it is by duplicating the handle. Tsss.. */ * way to do it is by duplicating the handle. Tsss.. */
if (!DuplicateHandle( GetCurrentProcess(), h, if (!DuplicateHandle( GetCurrentProcess(), h,
GetCurrentProcess(), &tmp, GetCurrentProcess(), &tmp,
SYNCHRONIZE, FALSE, 0 ) ) { EVENT_MODIFY_STATE|SYNCHRONIZE, FALSE, 0 ) ) {
DEBUG1 ("** Set SYNCRONIZE failed: ec=%d\n", (int)GetLastError()); DEBUG1 ("** Set SYNCRONIZE failed: ec=%d\n", (int)GetLastError());
} }
else { else {
@ -112,7 +112,8 @@ reader (void *arg)
/* leave a one byte gap so that we can see wheter it is empty or full*/ /* leave a one byte gap so that we can see wheter it is empty or full*/
if ((c->writepos + 1) % READBUF_SIZE == c->readpos) { if ((c->writepos + 1) % READBUF_SIZE == c->readpos) {
/* wait for space */ /* wait for space */
ResetEvent (c->have_space_ev); if (!ResetEvent (c->have_space_ev) )
DEBUG1 ("ResetEvent failed: ec=%d", (int)GetLastError ());
UNLOCK (c->mutex); UNLOCK (c->mutex);
DEBUG1 ("reader thread %p: waiting for space ...", c->thread_hd ); DEBUG1 ("reader thread %p: waiting for space ...", c->thread_hd );
WaitForSingleObject (c->have_space_ev, INFINITE); WaitForSingleObject (c->have_space_ev, INFINITE);
@ -149,11 +150,13 @@ reader (void *arg)
LOCK (c->mutex); LOCK (c->mutex);
c->writepos = (c->writepos + nread) % READBUF_SIZE; c->writepos = (c->writepos + nread) % READBUF_SIZE;
SetEvent (c->have_data_ev); if ( !SetEvent (c->have_data_ev) )
DEBUG1 ("SetEvent failed: ec=%d", (int)GetLastError ());
UNLOCK (c->mutex); UNLOCK (c->mutex);
} }
/* indicate that we have an error or eof */ /* indicate that we have an error or eof */
SetEvent (c->have_data_ev); if ( !SetEvent (c->have_data_ev) )
DEBUG1 ("SetEvent failed: ec=%d", (int)GetLastError ());
DEBUG1 ("reader thread %p ended", c->thread_hd ); DEBUG1 ("reader thread %p ended", c->thread_hd );
return 0; return 0;
@ -288,9 +291,11 @@ _gpgme_io_read ( int fd, void *buffer, size_t count )
memcpy (buffer, c->buffer+c->readpos, nread); memcpy (buffer, c->buffer+c->readpos, nread);
c->readpos = (c->readpos + nread) % READBUF_SIZE; c->readpos = (c->readpos + nread) % READBUF_SIZE;
if (c->readpos == c->writepos && !c->eof) { if (c->readpos == c->writepos && !c->eof) {
ResetEvent (c->have_data_ev); if ( !ResetEvent (c->have_data_ev) )
DEBUG1 ("ResetEvent failed: ec=%d", (int)GetLastError ());
} }
SetEvent (c->have_space_ev); if (!SetEvent (c->have_space_ev))
DEBUG1 ("SetEvent failed: ec=%d", (int)GetLastError ());
UNLOCK (c->mutex); UNLOCK (c->mutex);
DEBUG2 ("fd %d: got %d bytes\n", fd, nread ); DEBUG2 ("fd %d: got %d bytes\n", fd, nread );