From 25527a708349951052fe8af28fecfba2162976a7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= Date: Mon, 2 Jun 2008 17:06:40 +0000 Subject: [PATCH] Keep-alive feature in JP importer (WS and gridFTP). --- org.glite.jp.client/src/jpimporter.c | 25 +++++++++++++++++-------- org.glite.jp.primary/src/bones_server.c | 2 +- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/org.glite.jp.client/src/jpimporter.c b/org.glite.jp.client/src/jpimporter.c index e83b2dc..5cdb5d1 100644 --- a/org.glite.jp.client/src/jpimporter.c +++ b/org.glite.jp.client/src/jpimporter.c @@ -76,7 +76,7 @@ static char sandbox_mdir[PATH_MAX] = GLITE_SANDBOX_IMPORTER_MDIR; static char *store = NULL; static struct soap *soap; -static time_t cert_mtime; +static time_t cert_mtime = 0; static char *server_cert = NULL, *server_key = NULL, *cadir = NULL; @@ -91,6 +91,8 @@ typedef struct { int sink = 0; perf_t perf = {name:NULL,}; #endif +static int gftp_initialized = 0; +static globus_ftp_client_handle_t hnd; static struct option opts[] = { @@ -301,11 +303,13 @@ int main(int argc, char *argv[]) sigaddset(&sset, SIGINT); sigprocmask(SIG_BLOCK, &sset, NULL); - soap = soap_new(); - soap_init(soap); + soap = calloc(1, sizeof *soap); + soap_init2(soap, SOAP_IO_KEEPALIVE, SOAP_IO_KEEPALIVE); + soap_set_omode(soap, SOAP_IO_BUFFER); soap_set_namespaces(soap, jpps__namespaces); glite_gsplugin_init_context(&plugin_ctx); + glite_gsplugin_set_credential(plugin_ctx, mycred); soap_register_plugin_arg(soap, glite_gsplugin,plugin_ctx); if ( (reg_pid = slave(reg_importer, "reg-imp")) < 0 ) { @@ -430,6 +434,9 @@ static int slave(int (*fn)(void), const char *nm) dprintf("[%s] Terminating after %d connections\n", name, conn_cnt); if ( !debug ) syslog(LOG_INFO, "Terminating after %d connections", conn_cnt); + if (gftp_initialized--) + globus_ftp_client_handle_destroy(&hnd); + exit(0); } @@ -886,10 +893,10 @@ static void gftp_data_cb( static int gftp_put_file(const char *url, int fhnd) { - globus_ftp_client_handle_t hnd; - globus_ftp_client_operationattr_t op_attr; - globus_ftp_client_handleattr_t hnd_attr; + static globus_ftp_client_operationattr_t op_attr; + static globus_ftp_client_handleattr_t hnd_attr; + if (!gftp_initialized++) { #define put_file_err(errs) { \ dprintf("[%s] %s\n", name, errs); \ if ( !debug ) syslog(LOG_ERR, errs); \ @@ -898,6 +905,9 @@ static int gftp_put_file(const char *url, int fhnd) if ( globus_ftp_client_handleattr_init(&hnd_attr) != GLOBUS_SUCCESS ) put_file_err("Could not initialise handle attributes"); + if ( globus_ftp_client_handleattr_set_cache_all(&hnd_attr, GLOBUS_TRUE) != GLOBUS_SUCCESS) + put_file_err("Could not set connection caching"); + if ( globus_ftp_client_operationattr_init(&op_attr) != GLOBUS_SUCCESS ) put_file_err("Could not initialise operation attributes"); @@ -908,6 +918,7 @@ static int gftp_put_file(const char *url, int fhnd) if ( globus_ftp_client_handle_init(&hnd, &hnd_attr) != GLOBUS_SUCCESS ) put_file_err("Could not initialise ftp client handle"); + } #undef put_file_err globus_mutex_init(&gLock, GLOBUS_NULL); @@ -945,8 +956,6 @@ static int gftp_put_file(const char *url, int fhnd) while ( !gDone ) globus_cond_wait(&gCond, &gLock); globus_mutex_unlock(&gLock); - globus_ftp_client_handle_destroy(&hnd); - return (gError == GLOBUS_TRUE)? 1: 0; } diff --git a/org.glite.jp.primary/src/bones_server.c b/org.glite.jp.primary/src/bones_server.c index be568c7..1b90c44 100644 --- a/org.glite.jp.primary/src/bones_server.c +++ b/org.glite.jp.primary/src/bones_server.c @@ -362,7 +362,7 @@ static int request(int conn,struct timeval *to,void *data) fprintf(stderr,"[%d] %s\n",getpid(),e = glite_jp_error_chain(ctx)); free(e); } - return ENOTCONN; + return 0; } static int reject(int conn) -- 1.8.2.3