Skip to content

Commit a096e5d

Browse files
committed
add gobal variables for username, filename and event type
1 parent 483d40f commit a096e5d

3 files changed

Lines changed: 21 additions & 0 deletions

File tree

src/gridftp_hdfs.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ char err_msg[MSG_SIZE];
3030
int local_io_block_size = 0;
3131
int local_io_count = 0;
3232

33+
// global variable for username, filename and event type
34+
char gridftp_user_name[256];
35+
char gridftp_file_name[256];
36+
char gridftp_transfer_type[10];
37+
3338
static globus_mutex_t g_hdfs_mutex;
3439
static pthread_t g_thread_id;
3540
static int g_thread_pipe_fd;
@@ -603,12 +608,15 @@ hdfs_start(
603608
strlength = strlength < 256 ? strlength : 256;
604609
hdfs_handle->username = globus_malloc(sizeof(char)*strlength);
605610
if (hdfs_handle->username == NULL) {
611+
gridftp_user_name[0] = '\0';
606612
finished_info.result = GLOBUS_FAILURE;
607613
globus_gridftp_server_operation_finished(
608614
op, GLOBUS_FAILURE, &finished_info);
609615
return;
610616
}
611617
strncpy(hdfs_handle->username, session_info->username, strlength);
618+
// also copy username to global variable gridftp_user_name
619+
strncpy(gridftp_user_name, session_info->username, strlength);
612620

613621
// Pull configuration from environment.
614622
hdfs_handle->replicas = 3;

src/gridftp_hdfs_recv.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
#define ADVANCE_SLASHES(x) {while (x[0] == '/' && x[1] == '/') x++;}
66

7+
// extern global variable "gridftp_file_name"
8+
extern char gridftp_file_name[256];
9+
extern char gridftp_transfer_type[10];
10+
711
// Forward declarations of local functions
812
static void
913
hdfs_handle_write_op(
@@ -235,6 +239,9 @@ hdfs_recv(
235239

236240
hdfs_handle->op = op;
237241
hdfs_handle->pathname = transfer_info->pathname;
242+
// copy file name string to global variable
243+
strncpy(gridftp_file_name, transfer_info->pathname, strlen(transfer_info->pathname));
244+
strcpy(gridftp_transfer_type, "upload");
238245

239246
if ((rc = prepare_handle(hdfs_handle)) != GLOBUS_SUCCESS) goto cleanup;
240247

src/gridftp_hdfs_send.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
#include "gridftp_hdfs.h"
33
#include <syslog.h>
44

5+
extern char gridftp_file_name[256];
6+
extern char gridftp_transfer_type[10];
7+
58
// Forward declarations of local functions
69

710
typedef struct hdfs_read_s {
@@ -95,6 +98,9 @@ hdfs_send(
9598
globus_mutex_lock(hdfs_handle->mutex);
9699
hdfs_handle->pathname = transfer_info->pathname;
97100

101+
strncpy(gridftp_file_name, transfer_info->pathname, strlen(transfer_info->pathname));
102+
strcpy(gridftp_transfer_type, "download");
103+
98104
ADVANCE_SLASHES(hdfs_handle->pathname)
99105
if (strncmp(hdfs_handle->pathname, hdfs_handle->mount_point, hdfs_handle->mount_point_len)==0) {
100106
hdfs_handle->pathname += hdfs_handle->mount_point_len;

0 commit comments

Comments
 (0)