[PATCH gpgme v2 2/3] doc: Fix minor errors in I/O callback example
Daiki Ueno
ueno at gnu.org
Fri Feb 5 09:17:30 CET 2016
* gpgme.texi (I/O Callback Example): Fix typos and the select usage.
Signed-off-by: Daiki Ueno <ueno at gnu.org>
---
doc/gpgme.texi | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/doc/gpgme.texi b/doc/gpgme.texi
index db94617..28aa5e7 100644
--- a/doc/gpgme.texi
+++ b/doc/gpgme.texi
@@ -5830,6 +5830,8 @@ do_select (struct event_loop *loop)
fd_set wfds;
int i, n;
int any = 0;
+ int nfds = 0;
+ struct timeval tv;
struct one_fd *fdlist = loop->fds;
pthread_mutex_lock (&loop->lock);
@@ -5837,12 +5839,19 @@ do_select (struct event_loop *loop)
FD_ZERO (&wfds);
for (i = 0; i < MAX_FDS; i++)
if (fdlist[i].fd != -1)
- FD_SET (fdlist[i].fd, fdlist[i].dir ? &rfds : &wfds);
- pthread_mutex_unlock (&loop->unlock);
+ @{
+ FD_SET (fdlist[i].fd, fdlist[i].dir ? &rfds : &wfds);
+ if (nfds < fdlist[i].fd)
+ nfds = fdlist[i].fd;
+ @}
+ pthread_mutex_unlock (&loop->lock);
+
+ tv.tv_sec = 0;
+ tv.tv_usec = 1000;
do
@{
- n = select (FD_SETSIZE, &rfds, &wfds, NULL, 0);
+ n = select (nfds, &rfds, &wfds, NULL, &tv);
@}
while (n < 0 && errno == EINTR);
@@ -5905,7 +5914,7 @@ main (int argc, char *argv[])
&result
@};
- init_gpgme (void);
+ init_gpgme ();
/* Initialize the loop structure. */
pthread_mutex_init (&loop.lock, NULL);
--
2.5.0
More information about the Gnupg-devel
mailing list