diff options
author | David Shaw <[email protected]> | 2004-10-13 18:30:29 +0000 |
---|---|---|
committer | David Shaw <[email protected]> | 2004-10-13 18:30:29 +0000 |
commit | d603b7c3a16d4dfdbd26fa0ca28adf7ee850016e (patch) | |
tree | de899dab667bd80a7afa4cae558387db1682144c /keyserver/gpgkeys_http.c | |
parent | Added SELInux hacks and did some cleanups. (diff) | |
download | gnupg-d603b7c3a16d4dfdbd26fa0ca28adf7ee850016e.tar.gz gnupg-d603b7c3a16d4dfdbd26fa0ca28adf7ee850016e.zip |
* 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.
Diffstat (limited to '')
-rw-r--r-- | keyserver/gpgkeys_http.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/keyserver/gpgkeys_http.c b/keyserver/gpgkeys_http.c index 6eabdcff4..32700fbc9 100644 --- a/keyserver/gpgkeys_http.c +++ b/keyserver/gpgkeys_http.c @@ -31,6 +31,7 @@ #include "util.h" #include "http.h" #include "keyserver.h" +#include "ksutil.h" extern char *optarg; extern int optind; @@ -38,10 +39,10 @@ extern int optind; #define GET 0 #define MAX_LINE 80 -int verbose=0; -unsigned int http_flags=0; -char host[80]={'\0'},proxy[80]={'\0'},port[10]={'\0'},path[1024]={'\0'}; -FILE *input=NULL,*output=NULL,*console=NULL; +static int verbose=0; +static unsigned int http_flags=0; +static char host[80]={'\0'},proxy[80]={'\0'},port[10]={'\0'},path[1024]={'\0'}; +static FILE *input=NULL,*output=NULL,*console=NULL; #define BEGIN "-----BEGIN PGP PUBLIC KEY BLOCK-----" #define END "-----END PGP PUBLIC KEY BLOCK-----" @@ -128,6 +129,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; @@ -281,11 +283,24 @@ main(int argc,char *argv[]) else http_flags|=HTTP_FLAG_TRY_SRV; } + 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; + } + /* By suggested convention, if the user gives a :port, then disable SRV. */ if(port[0]) @@ -351,6 +366,8 @@ main(int argc,char *argv[]) fprintf(console,"Command:\tGET\n"); } + set_timeout(timeout); + ret=get_key(thekey); fail: |