1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-03 22:56:33 +02:00

* gpgkeys_ldap.c (main), gpgkeys_hkp.c (main), gpgkeys_http.c (main),

gpgkeys_finger.c (main): Call timeout functions before performing an
action that could block for a long time.

* ksutil.h, ksutil.c: New.  Right now just contains timeout functions.
This commit is contained in:
David Shaw 2004-10-13 18:30:29 +00:00
parent 151ca81f1a
commit d603b7c3a1
8 changed files with 194 additions and 10 deletions

View file

@ -44,6 +44,7 @@
#define INCLUDED_BY_MAIN_MODULE 1
#include "util.h"
#include "keyserver.h"
#include "ksutil.h"
#ifdef _WIN32
#define sock_close(a) closesocket(a)
@ -51,7 +52,6 @@
#define sock_close(a) close(a)
#endif
extern char *optarg;
extern int optind;
@ -65,7 +65,6 @@ static FILE *input, *output, *console;
#define BEGIN "-----BEGIN PGP PUBLIC KEY BLOCK-----"
#define END "-----END PGP PUBLIC KEY BLOCK-----"
#ifdef _WIN32
static void
deinit_sockets (void)
@ -364,6 +363,7 @@ main(int argc,char *argv[])
int arg,action=-1,ret=KEYSERVER_INTERNAL_ERROR;
char line[MAX_LINE];
char *thekey=NULL;
unsigned int timeout=DEFAULT_KEYSERVER_TIMEOUT;
console=stderr;
@ -472,11 +472,24 @@ main(int argc,char *argv[])
else
verbose++;
}
else if(strncasecmp(start,"timeout",7)==0)
{
if(no)
timeout=0;
else
timeout=atoi(&start[8]);
}
continue;
}
}
if(timeout && register_timeout()==-1)
{
fprintf(console,"gpgkeys: unable to register timeout handler\n");
return KEYSERVER_INTERNAL_ERROR;
}
/* If it's a GET or a SEARCH, the next thing to come in is the
keyids. If it's a SEND, then there are no keyids. */
@ -534,6 +547,8 @@ main(int argc,char *argv[])
fprintf(console,"Command:\tGET\n");
}
set_timeout(timeout);
ret = get_key(thekey);
fail: