From 17b6619a6bf76e1ecbae34b9179c096edd862210 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ale=C5=A1=20K=C5=99enek?= Date: Thu, 3 Mar 2005 16:15:16 +0000 Subject: [PATCH] correct timeout handling: 0 is polling, NULL is waiting indefinitely --- org.glite.security.gsoap-plugin/Makefile | 2 +- .../examples/wscalc_srv_ex2.c | 2 +- .../interface/glite_gsplugin.h | 7 +++--- .../project/version.properties | 2 +- .../src/glite_gsplugin.c | 26 ++++++++++++++++------ 5 files changed, 25 insertions(+), 14 deletions(-) diff --git a/org.glite.security.gsoap-plugin/Makefile b/org.glite.security.gsoap-plugin/Makefile index b737886..a772776 100644 --- a/org.glite.security.gsoap-plugin/Makefile +++ b/org.glite.security.gsoap-plugin/Makefile @@ -15,7 +15,7 @@ nothrflavour=gcc32 thrflavour=gcc32pthr gsoap_prefix=/opt/gsoap -CC?=gcc +CC=gcc -include Makefile.inc -include ../Makefile.inc diff --git a/org.glite.security.gsoap-plugin/examples/wscalc_srv_ex2.c b/org.glite.security.gsoap-plugin/examples/wscalc_srv_ex2.c index e32fc46..8a7c001 100644 --- a/org.glite.security.gsoap-plugin/examples/wscalc_srv_ex2.c +++ b/org.glite.security.gsoap-plugin/examples/wscalc_srv_ex2.c @@ -93,7 +93,7 @@ main(int argc, char **argv) perror("accept"); exit(1); } - if ( edg_wll_gss_accept(ctx->cred,conn,&ctx->timeout,ctx->connection,&gss_code) ){ + if ( edg_wll_gss_accept(ctx->cred,conn,ctx->timeout,ctx->connection,&gss_code) ){ edg_wll_gss_get_error(&gss_code, "Failed to read credential", &msg); fprintf(stderr, "%s\n", msg); free(msg); diff --git a/org.glite.security.gsoap-plugin/interface/glite_gsplugin.h b/org.glite.security.gsoap-plugin/interface/glite_gsplugin.h index b8fb4f8..1272a48 100644 --- a/org.glite.security.gsoap-plugin/interface/glite_gsplugin.h +++ b/org.glite.security.gsoap-plugin/interface/glite_gsplugin.h @@ -8,10 +8,7 @@ #define PLUGIN_ID "GLITE_GSOAP_PLUGIN" struct _glite_gsplugin_ctx { - struct timeval timeout; /**< timeout for all netcalls - * if tv_sec ==0 and tv_usec == 0 then - * no timeout is used - every call will - * be considered as a nonblocking */ + struct timeval _timeout, *timeout; char *error_msg; @@ -32,6 +29,8 @@ extern glite_gsplugin_Context glite_gsplugin_get_context(struct soap *); extern void *glite_gsplugin_get_udata(struct soap *); extern void glite_gsplugin_set_udata(struct soap *, void *); +extern void glite_gsplugin_set_timeout(glite_gsplugin_Context, struct timeval const *); + extern int glite_gsplugin(struct soap *, struct soap_plugin *, void *); extern char *glite_gsplugin_errdesc(struct soap *); diff --git a/org.glite.security.gsoap-plugin/project/version.properties b/org.glite.security.gsoap-plugin/project/version.properties index e22bcd3..3daa2fc 100644 --- a/org.glite.security.gsoap-plugin/project/version.properties +++ b/org.glite.security.gsoap-plugin/project/version.properties @@ -1,3 +1,3 @@ -module.version=1.0.0 +module.version=1.1.0 module.build=0 module.age=0 diff --git a/org.glite.security.gsoap-plugin/src/glite_gsplugin.c b/org.glite.security.gsoap-plugin/src/glite_gsplugin.c index 9c4b607..ff6d0f7 100644 --- a/org.glite.security.gsoap-plugin/src/glite_gsplugin.c +++ b/org.glite.security.gsoap-plugin/src/glite_gsplugin.c @@ -38,8 +38,10 @@ glite_gsplugin_init_context(glite_gsplugin_Context *ctx) out->cred = GSS_C_NO_CREDENTIAL; /* XXX: some troubles with glite_gss and blocking calls! - */ out->timeout.tv_sec = 10000; + */ + + out->timeout = NULL; *ctx = out; return 0; @@ -90,6 +92,16 @@ glite_gsplugin_set_udata(struct soap *soap, void *d) pdata->ctx->user_data = d; } +void glite_gsplugin_set_timeout(glite_gsplugin_Context ctx, struct timeval const *to) +{ + if (to) { + ctx->_timeout = *to; + ctx->timeout = &ctx->_timeout; + } + else ctx->timeout = NULL; +} + + int glite_gsplugin(struct soap *soap, struct soap_plugin *p, void *arg) { @@ -216,7 +228,7 @@ glite_gsplugin_connect( if ( !(ctx->connection = malloc(sizeof(*ctx->connection))) ) return errno; ret = edg_wll_gss_connect(ctx->cred, host, port, - (ctx->timeout.tv_usec || ctx->timeout.tv_sec)? &ctx->timeout: NULL, + ctx->timeout, ctx->connection, &gss_stat); if ( ret ) { edg_wll_gss_get_error(&gss_stat, "edg_wll_gss_connect()", &ctx->error_msg); @@ -252,8 +264,7 @@ glite_gsplugin_close(struct soap *soap) if ( ctx->connection ) { if ( ctx->connection->context != GSS_C_NO_CONTEXT) { pdprintf(("GSLITE_GSPLUGIN: closing gss connection\n")); - ret = edg_wll_gss_close(ctx->connection, - (ctx->timeout.tv_usec || ctx->timeout.tv_sec)? &ctx->timeout: NULL); + ret = edg_wll_gss_close(ctx->connection, ctx->timeout); } ctx->connection->context = GSS_C_NO_CONTEXT; } @@ -275,7 +286,7 @@ glite_gsplugin_accept(struct soap *soap, int s, struct sockaddr *a, int *n) if ( (conn = accept(s, (struct sockaddr *)&a, n)) < 0 ) return conn; if ( !ctx->connection && !(ctx->connection = malloc(sizeof(*ctx->connection))) ) return -1; - if ( edg_wll_gss_accept(ctx->cred, conn, &ctx->timeout, ctx->connection, &gss_code)) { + if ( edg_wll_gss_accept(ctx->cred, conn, ctx->timeout, ctx->connection, &gss_code)) { pdprintf(("GSLITE_GSPLUGIN: Client authentication failed, closing.\n")); edg_wll_gss_get_error(&gss_code, "Client authentication failed", &ctx->error_msg); return -1; @@ -304,7 +315,7 @@ glite_gsplugin_recv(struct soap *soap, char *buf, size_t bufsz) } len = edg_wll_gss_read(ctx->connection, buf, bufsz, - (ctx->timeout.tv_usec || ctx->timeout.tv_sec)? &ctx->timeout: NULL, + ctx->timeout, &gss_code); switch ( len ) { @@ -363,7 +374,7 @@ glite_gsplugin_send(struct soap *soap, const char *buf, size_t bufsz) sigaction(SIGPIPE, &sa, &osa); ret = edg_wll_gss_write_full(ctx->connection, - (void*)buf, bufsz, &ctx->timeout, &total, &gss_code); + (void*)buf, bufsz, ctx->timeout, &total, &gss_code); sigaction(SIGPIPE, &osa, NULL); @@ -397,3 +408,4 @@ glite_gsplugin_send(struct soap *soap, const char *buf, size_t bufsz) return SOAP_OK; } + -- 1.8.2.3